downshift version: 2.0.2node version: 8.11.2npm (or yarn) version: 6.1firefox version: 60.0.2What you did:
Open Firefox, go to the linked Storybook page, focus the button and then press the spacebar to open (or close) the menu.
What happened:
The menu opens but then closes right after. If you hold the spacebar down the menu will start to flicker between the open and close state.
I also noticed that the onChange event fires when pressing the spacebar, but the selectedItem argument is undefined.
<Downshift
onChange={(selectedItem /* this becomes undefined */) => {}}
/>
Reproduction repository:
http://downshift.netlify.com/?selectedKind=Examples&selectedStory=dropdown&full=0&addons=1&stories=1&panelRight=0
Problem description:
Suggested solution:
Not sure what causes the problem so hard to say, Firefox must handle some events differently is my guess.
After doing some more research it seems that Firefox does not respect event.preventDefault() on the onKeyDown event handler (still propagates to a click event).
A possible solution would be to add a onKeyUp event handler that executes event.preventDefault(), this will prevent Firefox from firing the click event when pressing the spacebar. Is this a viable solution or will it break something I'm unaware of?
Why don't you go ahead and open a PR, then we can check out the demos (your PR will automatically be deployed as a preview) in various browsers and see if that fixes it without breaking anything else.
Thanks!
:tada: This issue has been resolved in version 2.0.9 :tada:
The release is available on:
npm package (@latest dist-tag)Your semantic-release bot :package::rocket:
Most helpful comment
After doing some more research it seems that Firefox does not respect
event.preventDefault()on theonKeyDownevent handler (still propagates to a click event).A possible solution would be to add a
onKeyUpevent handler that executesevent.preventDefault(), this will prevent Firefox from firing the click event when pressing the spacebar. Is this a viable solution or will it break something I'm unaware of?