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

Multiline TextInput key handling: add check for first responder #2215

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

nakambo
Copy link
Collaborator

@nakambo nakambo commented Oct 8, 2024

Summary:

Consider a hypothetical situation where a multiline TextInput handles (by dequeueing from the event queue) Cmd+Enter. If the focus is on another control that also handles Cmd+Enter, then hitting Cmd+Enter will not reach this other control -- in fact it will perform the action for the former TextInput, as if it were focused!

performKeyEquivalent is documented to be called even if a view isn't first responder (this is for example how "Enter" binds to the default button on a dialog -- the default button doesn't need to be focused to respond to Enter), but since we override performKeyEquivalent to properly support certain keyboard shortcuts (like noted in #1867), the previous assumption on the actual use of performKeyEquivalent no longer holds -- it's only intended for keystrokes sent in focused state, so add that check.

Test Plan:

Manually tested affected scenario for correct behavior.

performKeyEquivalent is [documented](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/EventArchitecture.html#//apple_ref/doc/uid/10000060i-CH3-SW10) to be called even if a view isn't first responder (this is for example how "Enter" binds to the default button on a dialog, for example -- the default button doesn't need to be focused to respond to Enter), but since we override performKeyEquivalent to properly support certain keyboard shortcuts (like noted in #1867), the previous assumption on the actual use of performKeyEquivalent no longer holds -- it's *only* for keystrokes sent in focused state, so add that check.
@nakambo nakambo requested a review from Saadnajmi October 8, 2024 22:23
@nakambo nakambo requested a review from a team as a code owner October 8, 2024 22:23
@nakambo nakambo enabled auto-merge (squash) October 8, 2024 22:40
@Saadnajmi Saadnajmi merged commit 8cd5b67 into main Oct 9, 2024
11 of 13 checks passed
@Saadnajmi Saadnajmi deleted the nakambo/multiline-textview-key-equivalent-fix branch October 9, 2024 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants