[react-interactions] Add allowModifiers flag to FocusList + FocusTable#16971
[react-interactions] Add allowModifiers flag to FocusList + FocusTable#16971trueadm merged 2 commits intofacebook:masterfrom
Conversation
Details of bundled changes.Comparing: 6c73a1e...94266e9 react-interactions
|
de11108 to
33caccb
Compare
Move emulateBrowserTab Move emulateBrowserTab
33caccb to
7def627
Compare
| } | ||
| const key = event.key; | ||
|
|
||
| if (key === 'Tab') { |
There was a problem hiding this comment.
Given that "shift" is a modifier, and it impacts "Tab" (reverses the direction) it seems odd that we check for key === 'Tab' before bailing out if modifiers aren't allowed. Is this a bug?
There was a problem hiding this comment.
The modifiers logic is only for the keyboard arrow keys, not for Tab.
There was a problem hiding this comment.
I see. That wasn't super clear to me just looking at the code and going off of the name of the prop. Maybe some inline comment clarifying the intent could be helpful?
| } | ||
| const key = event.key; | ||
|
|
||
| if (key === 'Tab') { |
There was a problem hiding this comment.
I see. That wasn't super clear to me just looking at the code and going off of the name of the prop. Maybe some inline comment clarifying the intent could be helpful?
| return {}; | ||
| } | ||
|
|
||
| function hasModifierKey(event: KeyboardEvent): boolean { |
There was a problem hiding this comment.
This function is already in the 'shared' module
There was a problem hiding this comment.
I originally used that thinking the exact same thing, but it's actually slightly different as it expects a different event object (that it reads nativeEvent from). I'm not too bothered about duplication here, we can tidy up once we're happy with the moving parts. :)
This PR adds the
allowModifiersflag to theFocusListandFocusTablecomponents. This PR also changes the default behaviour for using arrow keys with modifier keys (they're now no-ops). I also moved some of the test code into a different module relating toemulateBrowserTabas per a follow up to @necolas's feedback.