Skip to content

Commit cdfeb07

Browse files
vzaidmanmeta-codesync[bot]
authored andcommitted
Cmd+D often fails to open the React Native Dev Menu bottom sheet (#58946)
Summary: Pull Request resolved: #58946 `RCTKeyCommands` ignored all registered key commands whenever any window had an active first responder (e.g. a focused `TextInput`), so Cmd+D intermittently failed to open the Dev Menu in the iOS Simulator / Mac Catalyst. Only unmodified key commands are now suppressed while a responder is active, so plain typing is still not intercepted while modifier shortcuts (Cmd+D, Cmd+R) fire reliably. Changelog: [iOS][Fixed] - Fix Cmd+D and other modifier key commands failing to open the Dev Menu when a view is the first responder Differential Revision: D114042042
1 parent 8d658f4 commit cdfeb07

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎packages/react-native/React/Base/RCTKeyCommands.m‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,13 @@ - (void)handleKeyUIEventSwizzle:(UIEvent *)event
137137
}
138138
}
139139

140-
// Ignore key commands (except escape) when there's an active responder
141-
if (!firstResponder) {
140+
// When there's an active responder, ignore key commands that don't use a
141+
// shortcut modifier (Command/Control/Option) so that typing into a focused
142+
// view (e.g. a text field) isn't intercepted. Shift and Caps Lock don't
143+
// count here since they're part of normal text input. Commands with a
144+
// shortcut modifier (e.g. Cmd+D to open the Dev Menu) should still fire.
145+
UIKeyModifierFlags shortcutModifiers = UIKeyModifierCommand | UIKeyModifierControl | UIKeyModifierAlternate;
146+
if (!firstResponder || (modifierFlags & shortcutModifiers) != 0) {
142147
[self RCT_handleKeyCommand:modifiedInput flags:modifierFlags];
143148
}
144149
}

0 commit comments

Comments
 (0)