-
Notifications
You must be signed in to change notification settings - Fork 646
Dropdown fix #499
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
Dropdown fix #499
Conversation
colebemis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks good to me. I can't think of any unintended consequences to this change off of the top of my head.
I have a more general question about the Dropdown API though. What's our recommended way of handling "selection" of a dropdown item? Dropdown.Item currently renders an li, so it wouldn't be accessible to add an onClick handler. I suppose we could the as prop to render a button instead of an li but the browser button styles break the dropdown item styles. Should we add an onSelect prop to Dropdown.Item like Reach UI? https://ui.reach.tech/menu-button
Co-Authored-By: Cole Bemis <colebemis@github.com>
|
@colebemis good catch! I was wondering that too when I was playing around with this today, but thought it was taken care of because that's how the dropdowns in blueprints function, BUT turns out we're creating a totally custom dropdown instead of using this one 😂 I need to spend some time thinking about the right API here |
|
It looks like I wonder if the right thing to do here is to actually use a ref and have the |
|
@colebemis and I talked about this and I agree that we should probably adopt the uncontrolled components convention by having a |
|
@colebemis refreshed a bit on why it's built with a list there - we're expecting users to add links or buttons as children of the |
|
I think this is ready for a final review now! |
|
Ok, so after some rabbit hole adventures, this will need to introduce a breaking change. In order to fix the original issue of dropdown menu item clicks being swallowed by the prevent default in the open/close functionality, I needed to introduce a I'm okay with this change because it seems a little silly to have 3 ways of using this component, and if the user really needs some special functionality to happen |

This PR removes an out of place
preventDefaultthat was stopping clicks on dropdown items from registering. I am honestly not 100% sure why I felt the need to add this in the first place but I tested out several different scenarios with different dropdowns on the page being open/etc and this should be safe to remove 👍Closes: #491 , thanks for the heads up @nicholaai!