Skip to content

Commit 5e3e4aa

Browse files
committed
Multi line text view key handling: add check for first responder
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.
1 parent a5b98ea commit 5e3e4aa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ - (void)deleteBackward {
577577
}
578578
#else // [macOS
579579
- (BOOL)performKeyEquivalent:(NSEvent *)event {
580-
if (!self.hasMarkedText && ![self.textInputDelegate textInputShouldHandleKeyEvent:event]) {
580+
if (self.window.firstResponder == self && !self.hasMarkedText && ![self.textInputDelegate textInputShouldHandleKeyEvent:event]) {
581581
return YES;
582582
}
583583

0 commit comments

Comments
 (0)