-
Notifications
You must be signed in to change notification settings - Fork 1.2k
keyUpEvents/keyDownEvents check code, not key #11049
Copy link
Copy link
Open
Labels
Area: KeyboardBreaking ChangeThis PR will break existing apps and should be part of the known breaking changes for the releaseThis PR will break existing apps and should be part of the known breaking changes for the releasePartner: FacebookWorkstream: Component ParityClose the parity gap between RNW and RN for core RN components and their supporting APIs.Close the parity gap between RNW and RN for core RN components and their supporting APIs.bug
Milestone
Metadata
Metadata
Assignees
Labels
Area: KeyboardBreaking ChangeThis PR will break existing apps and should be part of the known breaking changes for the releaseThis PR will break existing apps and should be part of the known breaking changes for the releasePartner: FacebookWorkstream: Component ParityClose the parity gap between RNW and RN for core RN components and their supporting APIs.Close the parity gap between RNW and RN for core RN components and their supporting APIs.bug
Problem Description
Per the keyboard API spec, the props
keyDownEventsandkeyUpEventsare used to specify which events should be marked as handled natively (so that they are only handled in JS). The spec says you specify an array ofIHandledKeyboardEventobjects, each of which contains akeyfield and booleans for the modifier keys:However, if we look a the actual type and implementation , we aren't checking the
keyfield, but instead thecodefield.These two differ quite heavily and make it harder to write cross platform code. Both rn-win32 and rn-macOS check the
keyfield in their respective implementation.This came up as an issue while I was working on FluentUI React Native, where I'm trying to write cross-platform keyboard handlers and having a very hard time :')
Steps To Reproduce
Look at
PressableExample.windows.jsand see that all the keyboarding examples have objects that look like[{code: 'keyW'}, {code: 'keyH'}]Expected Results
Should be more like
[{key:'W'},{key:'H'}]CLI version
n/a
Environment
Target Platform Version
None
Target Device(s)
Desktop
Visual Studio Version
None
Build Configuration
None
Snack, code example, screenshot, or link to a repository
I guess, this is my keyboard handler. The windows version of it is wrong because it uses key :')
https://github.com/microsoft/fluentui-react-native/blob/main/packages/utils/interactive-hooks/src/useKeyProps.ts