
Backstory So my team and I are trying to create our own reusable UI component library that's not based on any UI frameworks and everythi...
For further actions, you may consider blocking this person and/or reporting abuse
For further actions, you may consider blocking this person and/or reporting abuse
a bit modified version using "react-outside-click-handler" and "without styled-components":
this snippet might be reused too
Ah cool, thanks for sharing!
Project deadline around the corner, and you just saved me. Thanks mate :-)
Cheers! (from the future)
Thanks a lot for this nice codesandbox. it helped me a lot to get my DropDown component to work in quite a short amount of time.
I want to share my modified version as a sandbox link. I used TS and my own useHandleClickOutside hook, but you could also use Sergey's "react-outside-click-handler" dep. I don't think that makes any difference.
I modularised it to accept React.ReactNodes as dropdown items and some popper props.
codesandbox.io/s/1-react-popper-va...
App.tsx
Making that arrow work requires some reverse-engineering on your part. Long story short:
This is a great guide, thanks. Still struggling with random stuff about poppers in my own app but love this as a reference as the react-popper hooks example is too bare bones....
Random note: your code sandbox has this
background-color: "#FFF";
But I think it should be with no quotes
background-color: #FFF;
You're an absolute life saver! Thank you so much :')
Np andrew!
In the last example here, the popover closes even when an item inside the menu is clicked
You might want to use a useOutsideClick hook maybe? usehooks.com/useOnClickOutside/
That is the expected behavior of a dropdown component in my experience and the direction I was headed with this example. It is definitely a nice feature if you're looking to persist the visibility of the dropdown menu outside clicks. Thanks for the link!
It's funny how you clarified it way better than the official docs. Great work my man. I'm interested to know what happened to that PR! Would like to help!
Never got around to it, as we do. Did you ever end up looking into it?