Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to obtain refs to the underlying HTML elements without ReactDOM.findDOMNode #27

Open
christopherbot opened this issue May 24, 2019 · 0 comments

Comments

@christopherbot
Copy link

christopherbot commented May 24, 2019

My motivation for wanting a way to reference the underlying HTML elements of the Dropdown components is to enhance the scrolling functionality of my DropdownMenu implementation.

I have added arrow buttons to the top and bottom of my DropdownMenu that appear when there is hidden content in those directions. When clicked, I want these buttons to cause the the DropdownMenu to scroll in that direction by a certain amount.

I have the behaviour working using ReactDOM.findDOMNode but I would like to use a callback ref instead (coming from the discussion in this issue).

I believe a simple solution is for the DropdownMenu component to accept an onRef prop that forwards to the Component (seen below), something like ref={this.props.onRef} underneath style={style}:

<Component
{...props}
role="menu"
className={cx(className, {
[styles.dropdownMenu]: true,
[styles.selected]: activeMenuItems.length > 0,
[styles.pullRight]: !!pullRight
})}
style={style}
>

Are you open to something like this?

@christopherbot christopherbot changed the title No way to obtain refs to the underlying HTML elements No way to obtain refs to the underlying HTML elements without ReactDOM.findDOMNode May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants