forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 138
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
Return and Space keys do not trigger onPress events #1623
Merged
tom-un
merged 62 commits into
microsoft:main
from
tom-un:user/tomun/fixPressibilityKeyEvents
Jan 12, 2023
Merged
Return and Space keys do not trigger onPress events #1623
tom-un
merged 62 commits into
microsoft:main
from
tom-un:user/tomun/fixPressibilityKeyEvents
Jan 12, 2023
Conversation
This file contains 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
…iew." This reverts commit 5a67ae0.
tom-un
changed the title
Draft: Return and Space keys do not trigger onPress events
Return and Space keys do not trigger onPress events
Jan 8, 2023
4 tasks
mischreiber
reviewed
Jan 10, 2023
Saadnajmi
reviewed
Jan 12, 2023
Saadnajmi
approved these changes
Jan 12, 2023
Saadnajmi
approved these changes
Jan 12, 2023
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.
Saadnajmi
pushed a commit
to Saadnajmi/react-native-macos
that referenced
this pull request
Jan 12, 2023
* Update scripts to publish react-native-macos-init * Clean up merge markers * Restored ios:macos RNTester parity except for InputAccessoryView. * Revert "Restored ios:macos RNTester parity except for InputAccessoryView." This reverts commit 5a67ae0. * Remove unnecessary android builds and tar file upload. * Fix pressability enter/return and spacebar key events * Don't change validKeysDown/Up for components that explicitly set them * Added event.defaultPrevented check to key events * Fixed spacing in RCTView.m * Ignore key event props not matching press events Co-authored-by: React-Native Bot <[email protected]>
Saadnajmi
added a commit
that referenced
this pull request
Jan 12, 2023
* Update scripts to publish react-native-macos-init * Clean up merge markers * Restored ios:macos RNTester parity except for InputAccessoryView. * Revert "Restored ios:macos RNTester parity except for InputAccessoryView." This reverts commit 5a67ae0. * Remove unnecessary android builds and tar file upload. * Fix pressability enter/return and spacebar key events * Don't change validKeysDown/Up for components that explicitly set them * Added event.defaultPrevented check to key events * Fixed spacing in RCTView.m * Ignore key event props not matching press events Co-authored-by: React-Native Bot <[email protected]> Co-authored-by: Tom Underhill <[email protected]> Co-authored-by: React-Native Bot <[email protected]>
4 tasks
shwanton
pushed a commit
to shwanton/react-native-macos
that referenced
this pull request
Feb 13, 2023
…icrosoft#1632) * Update scripts to publish react-native-macos-init * Clean up merge markers * Restored ios:macos RNTester parity except for InputAccessoryView. * Revert "Restored ios:macos RNTester parity except for InputAccessoryView." This reverts commit 5a67ae0. * Remove unnecessary android builds and tar file upload. * Fix pressability enter/return and spacebar key events * Don't change validKeysDown/Up for components that explicitly set them * Added event.defaultPrevented check to key events * Fixed spacing in RCTView.m * Ignore key event props not matching press events Co-authored-by: React-Native Bot <[email protected]> Co-authored-by: Tom Underhill <[email protected]> Co-authored-by: React-Native Bot <[email protected]>
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.
Please select one of the following
Summary
This is a fix for Issue 1622 . This fixes a regression that was introduced in .68 when the
validKeysDown
/validKeysUp
View props were introduced. Since then various Pressability components (Pressable, and Touchable*) do not triggeronPress
events when the Return or Spacebar key is pressed.The fix involves triggering the
onPressIn
andonPressOut
events inPressibility
'sonKeyDown
/onKeyUp
handlers similar to howreact-native-windows
also does this: https://github.com/microsoft/react-native-windows/blob/main/vnext/src/Libraries/Pressability/Pressability.windows.js. It also triggers theonPress
on key down which mimics how most macOS controls respond to key down as a click in contrast to Windows which triggersonPress
on key up.Logic was also added to
RCTView
'skeyboardEvent:
filtering logic: if the view is focusable and it does not havevalidKeyDown/Up
props, it implicitly allows the Return and Spacebar keys.Changelog
[macOS] [Fix] - Return and Space keys do not trigger onPress events
Test Plan
All the Pressable and Touchable pages in RNTester were tested:
Note that this change is very similar to Saad's PR here: #1614. The changes to
Pressability
event handlers are identical in both PRs. But in Saad's thevalidKeysDown
prop is giving a default value of Enter and Space in the Pressability.js while this PR makes the default values of thevalidKeysDown/Up
in the nativeRCTView
. The advantage of doing it in the native side means that the Touchable* components also get the correct behavior without making very large scale changes to the various Touchable* files -- Saad's change only fixes Pressable. Also the other PR only makes default values forvalidKeysDown
and not alsovalidKeysUp
, so the Press Out effects never trigger leaving the component in a "stuck" state. Here is a sample of the Pressable test in the other branch: