[0.66] Don't override key presses "Space"/"Enter" to perform onClick in RCTV… #972
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.
Cherry pick #941 into 0.66-Stable
Please select one of the following
Summary
When we added keyboarding support to react-native-macos, we set it so that if 'Space' or 'Enter' was pressed while an RCTView is in focus, it would perform the
onClick
handler. This causes a few problems, namely, there's no way to override this in JS. If you only wantedonClick
to fireonKeyUp
instead ofonKeyDown
, you have no way to do that.We seemingly did this because the original Keyboarding API proposal wanted basic defaults on JS components. If we look closer at the API proposal however, it actually says we should provide defaults for Button / Touchable / Pressable, not View. I am in favor of not having defaults on View, which should be a primitive and make no assumptions.
Unfortunately, I don't have an easy way to set defaults on, say, Pressable ( (Space/Enter to activate
onPress
) because then I have to overridevalidKeys(Up|Down)
, which means that the developer can't override any other keys. This is a limitation of our implementation of keyboarding on react-native-macos, so I'll leave changing that / settings defaults on Pressable as outside this review.Changelog
[macOS] [Removed] - Removed 'Space'/'Enter' keypresses calling onClick by default.
Test Plan
In a separate repo (FluentUI Raect Native), I locally commented out this code and fixed my issue where I wanted to override
onKeyUp
and notonKeyDown
.