Fix usePress with HTML input elements#3446
Merged
Merged
Conversation
|
Build successful! 🎉 |
Member
Author
|
One slight change is that the Enter key on checkboxes will now bubble since the checkbox doesn't handle it, so table row selection will toggle in that case as well. I think this is ok? |
LFDanLu
approved these changes
Aug 25, 2022
Member
LFDanLu
left a comment
There was a problem hiding this comment.
Did some basic testing, confirmed table select all checkbox is working now. Other components seem to work still (form submit/reset buttons, checkboxes, etc), deeper sweep to come tmrw
Comment on lines
+788
to
+798
| const nonTextInputTypes = new Set([ | ||
| 'checkbox', | ||
| 'radio', | ||
| 'range', | ||
| 'color', | ||
| 'file', | ||
| 'image', | ||
| 'button', | ||
| 'submit', | ||
| 'reset' | ||
| ]); |
Member
There was a problem hiding this comment.
How was this list generated? I assume by going through a list of input types and adding any that wasn't a text input?
Member
Author
There was a problem hiding this comment.
reidbarber
approved these changes
Aug 25, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes usePress work better with HTML
<input>elements, which have default keyboard behavior. For example, checkboxes toggle when the space key is pressed. Previously this was somewhat broken, in that onPressStart would only be triggered on key up due to the browser firing a virtual onClick event.In #3380, I changed usePress to look at the currentTarget rather than target when determining whether to handle an event. This caused TableView's select all checkbox to stop working, because the event would bubble to the cell and get handled there (with preventDefault).
Now we allow the space key for checkboxes and other input elements to trigger onPressStart on key down, but do not call
preventDefault, allowing the browser to toggle the checkbox.