-
Notifications
You must be signed in to change notification settings - Fork 5.5k
fix: prevent "space" on input to open dropdown #10715
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
Conversation
js/foundation.dropdown.js
Outdated
@@ -178,7 +178,7 @@ class Dropdown extends Positionable { | |||
|
|||
Keyboard.handleKey(e, 'Dropdown', { | |||
open: function() { | |||
if ($target.is(_this.$anchors)) { | |||
if ($target.is(_this.$anchors) && !$target.is('input')) { |
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.
Not only input
should be able to get a space
without losing the focus. I think we have two solutions:
- determine all the native elements that should be able to receive
space
and make a big filter - add an option to the
dropdown
element to prevent the keyboard catching
Good finding with the |
Why |
Sorry, I just realized now that I was in a different context. you are correct. |
See: #10899 (including new feature to control the keyboard on Dropdown), based on this PR. |
…r v6.5.0 848e9c0 Added visual test for a Dropdown attached to an input element. 2d736a1 Prevent SPACE from setting focus to the Dropdown if anchor is an input element. 87c3d4f Added unittest for keyboard events for Dropdown. 64e5ede feat: ignore dropdown keyboard event on textarea Co-Authored-By: Nicolas Coden <[email protected]> Signed-off-by: Nicolas Coden <[email protected]>
I had the usecase where I used a Dropdown as a auto-completion/suggestion feature. The Dropdown was attached to an input element and shows when the input has focus. Issue was then, that everytime a space was entered into the input, the Dropdown would receive focus and prevent the typing within the input.
I am not sure, whether this is too specific or not to become part of the code base.