Skip to content

Commit 5856e32

Browse files
committed
Remove validKeysDown, validKeysUp, passThroughAllKeyEvents
1 parent 6d4a0b1 commit 5856e32

File tree

21 files changed

+103
-387
lines changed

21 files changed

+103
-387
lines changed

packages/react-native/Libraries/Components/Button.js

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@
1212

1313
import type {TextStyleProp, ViewStyleProp} from '../StyleSheet/StyleSheet';
1414
import type {PressEvent} from '../Types/CoreEventTypes';
15-
import type {
16-
BlurEvent,
17-
FocusEvent,
18-
HandledKeyEvent,
19-
KeyEvent,
20-
} from '../Types/CoreEventTypes'; // [macOS]
15+
import type {BlurEvent, FocusEvent} from '../Types/CoreEventTypes'; // [macOS]
2116
import type {
2217
AccessibilityActionEvent,
2318
AccessibilityActionInfo,
@@ -171,56 +166,6 @@ type ButtonProps = $ReadOnly<{|
171166
*/
172167
onFocus?: ?(e: FocusEvent) => void,
173168

174-
/**
175-
* Handler to be called when a key down press is detected
176-
*/
177-
onKeyDown?: ?(e: KeyEvent) => void,
178-
179-
/**
180-
* Handler to be called when a key up press is detected
181-
*/
182-
onKeyUp?: ?(e: KeyEvent) => void,
183-
184-
/*
185-
* @deprecated use `keyDownEvents` or `keyUpEvents` instead
186-
* Array of keys to receive key down events for
187-
* For arrow keys, add "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
188-
*/
189-
validKeysDown?: ?Array<string>,
190-
191-
/*
192-
* @deprecated use `keyDownEvents` or `keyUpEvents` instead
193-
* Array of keys to receive key up events for
194-
* For arrow keys, add "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
195-
*/
196-
validKeysUp?: ?Array<string>,
197-
198-
/**
199-
* @deprecated use `keyDownEvents` or `keyUpEvents` instead
200-
* When `true`, allows `onKeyDown` and `onKeyUp` to receive events not specified in
201-
* `validKeysDown` and `validKeysUp`, respectively. Events matching `validKeysDown` and `validKeysUp`
202-
* are still removed from the event queue, but the others are not.
203-
*
204-
* @platform macos
205-
*/
206-
passthroughAllKeyEvents?: ?boolean,
207-
208-
/**
209-
* Array of keys to receive key down events for. These events have their default native behavior prevented.
210-
* Overrides the props `validKeysDown`, `validKeysUp` and `passthroughAllKeyEvents`
211-
*
212-
* @platform macos
213-
*/
214-
keyDownEvents?: ?Array<HandledKeyEvent>,
215-
216-
/**
217-
* Array of keys to receive key up events for. These events have their default native behavior prevented.
218-
* Overrides the props `validKeysDown`, `validKeysUp` and `passthroughAllKeyEvents`
219-
*
220-
* @platform macos
221-
*/
222-
keyUpEvents?: ?Array<HandledKeyEvent>,
223-
224169
/*
225170
* Specifies the Tooltip for the view
226171
*/
@@ -396,8 +341,6 @@ const Button: React.AbstractComponent<ButtonProps> = (props: ButtonProps) => {
396341
// [macOS
397342
onFocus,
398343
onBlur,
399-
onKeyDown,
400-
onKeyUp,
401344
tooltip,
402345
// macOS]
403346
} = props;

packages/react-native/Libraries/Components/Pressable/Pressable.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -186,30 +186,6 @@ type Props = $ReadOnly<{|
186186
*/
187187
onKeyUp?: ?(event: KeyEvent) => void,
188188

189-
/**
190-
* Array of keys to receive key down events for. These events have their default native behavior prevented.
191-
*
192-
* @platform macos
193-
*/
194-
validKeysDown?: ?Array<string | HandledKeyEvent>,
195-
196-
/**
197-
* Array of keys to receive key up events for. These events have their default native behavior prevented.
198-
*
199-
* @platform macos
200-
*/
201-
validKeysUp?: ?Array<string | HandledKeyEvent>,
202-
203-
/**
204-
* @deprecated use `keyDownEvents` or `keyUpEvents` instead
205-
* When `true`, allows `onKeyDown` and `onKeyUp` to receive events not specified in
206-
* `validKeysDown` and `validKeysUp`, respectively. Events matching `validKeysDown` and `validKeysUp`
207-
* are still removed from the event queue, but the others are not.
208-
*
209-
* @platform macos
210-
*/
211-
passthroughAllKeyEvents?: ?boolean,
212-
213189
/**
214190
* Array of keys to receive key down events for. These events have their default native behavior prevented.
215191
* Overrides the props `validKeysDown`, `validKeysUp` and `passthroughAllKeyEvents`
@@ -374,7 +350,6 @@ function Pressable(props: Props, forwardedRef): React.Node {
374350
onBlur,
375351
onKeyDown,
376352
onKeyUp,
377-
passthroughAllKeyEvents,
378353
keyDownEvents,
379354
keyUpEvents,
380355
acceptsFirstMouse,

packages/react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import type {EdgeInsetsOrSizeProp} from '../../StyleSheet/EdgeInsetsPropType';
1919
import type {
2020
BlurEvent,
2121
FocusEvent,
22-
KeyEvent,
2322
LayoutEvent,
2423
MouseEvent,
2524
PressEvent,

packages/react-native/Libraries/Components/View/ReactNativeViewAttributes.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ const UIView = {
4848
onDrop: true,
4949
onKeyDown: true,
5050
onKeyUp: true,
51-
validKeysDown: true,
52-
validKeysUp: true,
53-
passthroughAllKeyEvents: true,
5451
keyDownEvents: true,
5552
keyUpEvents: true,
5653
draggedTypes: true,

packages/react-native/Libraries/Components/View/ViewPropTypes.d.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,8 @@ export interface ViewPropsMacOS {
179179
onDrop?: ((event: MouseEvent) => void) | undefined;
180180
onKeyDown?: ((event: KeyEvent) => void) | undefined;
181181
onKeyUp?: ((event: KeyEvent) => void) | undefined;
182-
validKeysDown?: Array<HandledKeyEvent | string> | undefined;
183-
validKeysUp?: Array<HandledKeyEvent | string> | undefined;
184-
passthroughAllKeyEvents?: boolean | undefined;
185-
keyDownEvents?: Array<HandledKeyEvent> | undefined;
186-
keyUpEvents?: Array<HandledKeyEvent> | undefined;
182+
keyDownEvents?: HandledKeyEvent[] | undefined;
183+
keyUpEvents?: HandledKeyEvent[] | undefined;
187184
draggedTypes?: DraggedTypesType | undefined;
188185
}
189186

packages/react-native/Libraries/Components/View/ViewPropTypes.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -111,30 +111,6 @@ export type KeyboardEventProps = $ReadOnly<{|
111111
*/
112112
onKeyUp?: ?(event: KeyEvent) => void,
113113

114-
/**
115-
* Array of keys to receive key down events for. These events have their default native behavior prevented.
116-
*
117-
* @platform macos
118-
*/
119-
validKeysDown?: ?Array<string | HandledKeyEvent>,
120-
121-
/**
122-
* Array of keys to receive key up events for. These events have their default native behavior prevented.
123-
*
124-
* @platform macos
125-
*/
126-
validKeysUp?: ?Array<string | HandledKeyEvent>,
127-
128-
/**
129-
* @deprecated use `keyDownEvents` or `keyUpEvents` instead
130-
* When `true`, allows `onKeyDown` and `onKeyUp` to receive events not specified in
131-
* `validKeysDown` and `validKeysUp`, respectively. Events matching `validKeysDown` and `validKeysUp`
132-
* are still removed from the event queue, but the others are not.
133-
*
134-
* @platform macos
135-
*/
136-
passthroughAllKeyEvents?: ?boolean,
137-
138114
/**
139115
* Array of keys to receive key down events for. These events have their default native behavior prevented.
140116
* Overrides the props `validKeysDown`, `validKeysUp` and `passthroughAllKeyEvents`

packages/react-native/Libraries/NativeComponent/BaseViewConfig.macos.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ const validAttributesForNonEventProps = {
5353
draggedTypes: true,
5454
enableFocusRing: true,
5555
tooltip: true,
56-
validKeysDown: true,
57-
validKeysUp: true,
58-
passthroughAllKeyEvents: true,
5956
keyDownEvents: true,
6057
keyUpEvents: true,
6158
mouseDownCanMoveWindow: true,

packages/react-native/Libraries/Pressability/Pressability.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,15 @@ export type PressabilityConfig = $ReadOnly<{|
101101
// [macOS
102102
/*
103103
* Called after a key down event is detected.
104+
*
105+
* @platform macos
104106
*/
105107
onKeyDown?: ?(event: KeyEvent) => void,
106108

107109
/*
108110
* Called after a key up event is detected.
111+
*
112+
* @platform macos
109113
*/
110114
onKeyUp?: ?(event: KeyEvent) => void,
111115
// macOS]

packages/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN
4848
#if TARGET_OS_OSX // [macOS
4949
- (BOOL)textInputShouldHandleDeleteForward:(id<RCTBackedTextInputViewProtocol>)sender; // Return `YES` to have the deleteForward event handled normally. Return `NO` to disallow it and handle it yourself.
5050
- (BOOL)textInputShouldHandleKeyEvent:(NSEvent *)event; // Return `YES` to have the key event handled normally. Return `NO` to disallow it and handle it yourself.
51-
- (BOOL)hasValidKeyDownOrValidKeyUp:(NSString *)key;
51+
- (BOOL)hasKeyDownEventOrKeyUpEvent:(NSString *)key;
5252
- (NSDragOperation)textInputDraggingEntered:(id<NSDraggingInfo>)draggingInfo;
5353
- (void)textInputDraggingExited:(id<NSDraggingInfo>)draggingInfo;
5454
- (BOOL)textInputShouldHandleDragOperation:(id<NSDraggingInfo>)draggingInfo;

packages/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ - (BOOL)control:(NSControl *)control textView:(NSTextView *)fieldEditor doComman
228228
//escape
229229
} else if (commandSelector == @selector(cancelOperation:)) {
230230
[textInputDelegate textInputDidCancel];
231-
if (![textInputDelegate hasValidKeyDownOrValidKeyUp:@"Escape"]) {
231+
if (![textInputDelegate hasKeyDownEventOrKeyUpEvent:@"Escape"]) {
232232
[[_backedTextInputView window] makeFirstResponder:nil];
233233
}
234234
commandHandled = YES;
@@ -450,7 +450,7 @@ - (BOOL)textView:(NSTextView *)textView doCommandBySelector:(SEL)commandSelector
450450
//escape
451451
} else if (commandSelector == @selector(cancelOperation:)) {
452452
[textInputDelegate textInputDidCancel];
453-
if (![textInputDelegate hasValidKeyDownOrValidKeyUp:@"Escape"]) {
453+
if (![textInputDelegate hasKeyDownEventOrKeyUpEvent:@"Escape"]) {
454454
[[_backedTextInputView window] makeFirstResponder:nil];
455455
}
456456
commandHandled = YES;

0 commit comments

Comments
 (0)