-
Notifications
You must be signed in to change notification settings - Fork 933
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
parent.contains is not a function when used with styled components #490
Comments
I think the problem is that the <Dropdown isOpen={isOpen} {...getMenuProps({ refKey: 'innerRef' })} /> Altough we should probably add a check if the |
Agreed. I'd accept a PR for that 👍 |
Yep that fixed it, thanks very much @alexandernanberg :) |
@kentcdodds Been thinking a bit more about this one. Wouldn't it be good to also print a warning when this happens? The |
Also, it seems it's not in type definitions. |
Yes, we should log a warning 👍 |
And we should add type definitions. |
If nobody is working on this, I’ll take a stab later.
… On Jun 29, 2018, at 6:23 AM, Kent C. Dodds ***@***.***> wrote:
And we should add type definitions.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Is there any update on this, I'm still hitting it in my codebase. |
@xshyne88, this is the solution: #490 (comment) |
Uh... I need some help here... I applied my code looks something like below, where I applied <SomeCompositeComponent>
<div {...getMenuProps()}>
{here goes the menu items}
</div>
</SomeCompositeComponent> I thought we only need to specify a I literally have no idea how to fix this. Please help! Thanks! |
Hmmm... I'm unable to reproduce this: https://codesandbox.io/s/github/kentcdodds/downshift-examples/tree/master/?module=%2Fsrc%2Fordered-examples%2F01-basic-autocomplete.js&moduleview=1 |
@kentcdodds Okay I found the problem. I was mounting and unmounting the entire menu as needed. Apparently menu is meant to be mounted all the time. Not sure if we want to document this explicitly? |
Yes, for accessibility reasons it should always be rendered. Feel free to make a PR to improve docs. I think it is mentioned but could probably be called out better. |
🎉 This issue has been resolved in version 2.1.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
* Improved typings for getMenuProps Fixes the typing part of #490 * Update index.d.ts * Fixed build error * Update index.d.ts
…downshift-js#492) * fix(utils): Checking if parent.contains is a function before using it Closes downshift-js#490 * chore: Adding myself as a contributor
* Improved typings for getMenuProps Fixes the typing part of downshift-js#490 * Update index.d.ts * Fixed build error * Update index.d.ts
downshift
version: 2.0.10node
version: 9.5.0npm
(oryarn
) version: 1.5.1Relevant code or config
What you did:
The code above is pseudo code but roughly equates to what I am doing. I am building a dropdown using downshift that toggles when you click a button. I am combining this with styled components and when I click outside of the div I am getting an error from within downshift.
What happened:
The error that I am getting is the following:
When digging deeper into this, it's because the parent in isOrContainsNode is coming through as a Styled Component wrapper as you can see in the screenshot below:
Problem description:
Clicking outside of the downshift container div when using styled components is throwing an error and the dropdown window stays open.
The text was updated successfully, but these errors were encountered: