Skip to content
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

Don't depend on isFullKeyboardAccessEnabled for keyboard focus #1007

Closed
Saadnajmi opened this issue Feb 4, 2022 · 1 comment
Closed

Don't depend on isFullKeyboardAccessEnabled for keyboard focus #1007

Saadnajmi opened this issue Feb 4, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Saadnajmi
Copy link
Collaborator

Environment

n/a

Steps to reproduce the bug

Currently setting focusable on a View only works if you have a specific system preference enabled. This also blocks keyboard events (onKeyDown/onKeyUp) from happening. This is pretty unknown and slightly annoying. Let's fix this by simply removing the check on this line

return ([self focusable] && [NSApp isFullKeyboardAccessEnabled]) || [super acceptsFirstResponder];

See https://microsoft.github.io/apple-ux-guide/KeyboardFocus.html

Expected Behavior

Keyboard events and keyboard focus work without having to know about the system preference.

Actual Behavior

Keyboard events and keyboard focus don't work at all without that preference.

Reproducible Demo

Go to the keyboard events page of RNTester.

Additional context

No response

@Saadnajmi
Copy link
Collaborator Author

I looked into this more, and it seems on apple platforms it's expected that not every control has keyboard focus by default. In general, only text input fields have keyboard access and you toggle the system preference "isFullKeyboardAccessEnabled" to add every other control with keyboard interaction to your key-view loop. As of iOS 13.4, this seems to be true on iOS as well, referring to this WWDC talk (Around timestamp 12:20): https://developer.apple.com/videos/play/wwdc2021/10120/.

So ideally , the React Native focusable prop would be more like an enum: [ .never, .withFullKeyboardAccess, .always] so that users could have better fine grained control over what has keyboard access in JS. That would be a breaking change, so we don't want to do that.

Instead, I think this would be an excellent topic to revisit if/when React Native Core adds keyboard support on iOS. It seems that iOS and macOS share similar API's and expectations around keyboard focus, so there's opportunity to share an API rather than have React Native macOS have it's own separate API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants