Skip to content

Commit da197bd

Browse files
committed
Remove validKeysDown, validKeysUp, and passThroughAllKeyEvents
1 parent acdd184 commit da197bd

File tree

22 files changed

+90
-368
lines changed

22 files changed

+90
-368
lines changed

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

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -176,42 +176,29 @@ type ButtonProps = $ReadOnly<{|
176176
*/
177177
onKeyUp?: ?(e: KeyEvent) => void,
178178

179-
/*
180-
* @deprecated use `keyDownEvents` or `keyUpEvents` instead
181-
* Array of keys to receive key down events for
182-
* For arrow keys, add "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
183-
*/
184-
validKeysDown?: ?Array<string>,
185-
186-
/*
187-
* @deprecated use `keyDownEvents` or `keyUpEvents` instead
188-
* Array of keys to receive key up events for
189-
* For arrow keys, add "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
179+
/**
180+
* Array of keys to receive key down events for. These events have their default native behavior prevented.
181+
*
182+
* @platform macos
190183
*/
191-
validKeysUp?: ?Array<string>,
192-
184+
keyDownEvents?: ?Array<HandledKeyboardEvent>,
193185

194186
/**
195-
* @deprecated use `keyDownEvents` or `keyUpEvents` instead
196-
* When `true`, allows `onKeyDown` and `onKeyUp` to receive events not specified in
197-
* `validKeysDown` and `validKeysUp`, respectively. Events matching `validKeysDown` and `validKeysUp`
198-
* are still removed from the event queue, but the others are not.
187+
* Array of keys to receive key up events for. These events have their default native behavior prevented.
199188
*
200189
* @platform macos
201190
*/
202-
passthroughAllKeyEvents?: ?boolean,
191+
keyUpEvents?: ?Array<HandledKeyboardEvent>,
203192

204193
/**
205194
* Array of keys to receive key down events for. These events have their default native behavior prevented.
206-
* Overrides the props `validKeysDown`, `validKeysUp` and `passthroughAllKeyEvents`
207195
*
208196
* @platform macos
209197
*/
210198
keyDownEvents?: ?Array<HandledKeyboardEvent>,
211199

212200
/**
213201
* Array of keys to receive key up events for. These events have their default native behavior prevented.
214-
* Overrides the props `validKeysDown`, `validKeysUp` and `passthroughAllKeyEvents`
215202
*
216203
* @platform macos
217204
*/
@@ -394,9 +381,6 @@ const Button: React.AbstractComponent<ButtonProps> = (props: ButtonProps) => {
394381
onBlur,
395382
onKeyDown,
396383
onKeyUp,
397-
validKeysDown,
398-
validKeysUp,
399-
passthroughAllKeyEvents,
400384
keyDownEvents,
401385
keyUpEvents,
402386
tooltip,
@@ -475,6 +459,8 @@ const Button: React.AbstractComponent<ButtonProps> = (props: ButtonProps) => {
475459
onBlur={onBlur}
476460
onKeyDown={onKeyDown}
477461
onKeyUp={onKeyUp}
462+
keyDownEvents={keyDownEvents}
463+
keyUpEvents={keyUpEvents}
478464
tooltip={tooltip}
479465
// macOS]
480466
touchSoundDisabled={touchSoundDisabled}>

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

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -191,36 +191,10 @@ type Props = $ReadOnly<{|
191191
*
192192
* @platform macos
193193
*/
194-
validKeysDown?: ?Array<string | HandledKeyboardEvent>,
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 | HandledKeyboardEvent>,
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-
213-
/**
214-
* Array of keys to receive key down events for. These events have their default native behavior prevented.
215-
* Overrides the props `validKeysDown`, `validKeysUp` and `passthroughAllKeyEvents`
216-
*
217-
* @platform macos
218-
*/
219194
keyDownEvents?: ?Array<HandledKeyboardEvent>,
220195

221196
/**
222197
* Array of keys to receive key up events for. These events have their default native behavior prevented.
223-
* Overrides the props `validKeysDown`, `validKeysUp` and `passthroughAllKeyEvents`
224198
*
225199
* @platform macos
226200
*/
@@ -374,7 +348,6 @@ function Pressable(props: Props, forwardedRef): React.Node {
374348
onBlur,
375349
onKeyDown,
376350
onKeyUp,
377-
passthroughAllKeyEvents,
378351
keyDownEvents,
379352
keyUpEvents,
380353
acceptsFirstMouse,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ const PASSTHROUGH_PROPS = [
135135
'onDragLeave',
136136
'onDrop',
137137
'draggedTypes',
138+
'onKeyDown',
139+
'onKeyUp',
140+
'keyDownEvents',
141+
'keyUpEvents',
138142
'tooltip', // macOS]
139143
'testID',
140144
];

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/View.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@ const View: React.AbstractComponent<
5555
nativeID,
5656
pointerEvents,
5757
tabIndex,
58-
// [macOS
59-
passthroughAllKeyEvents,
60-
validKeysDown,
61-
validKeysUp,
62-
keyDownEvents,
63-
keyUpEvents,
64-
// macOS]
6558
...otherProps
6659
}: ViewProps,
6760
forwardedRef,
@@ -109,17 +102,6 @@ const View: React.AbstractComponent<
109102
// $FlowFixMe[sketchy-null-mixed]
110103
const newPointerEvents = style?.pointerEvents || pointerEvents;
111104

112-
// [macOS
113-
let _passthroughAllKeyEvents = passthroughAllKeyEvents;
114-
let _validKeysDown = validKeysDown;
115-
let _validKeysUp = validKeysUp;
116-
if (keyDownEvents || keyUpEvents) {
117-
_passthroughAllKeyEvents = true;
118-
_validKeysDown = keyDownEvents;
119-
_validKeysUp = keyUpEvents;
120-
}
121-
// macOS]
122-
123105
const actualView = (
124106
<ViewNativeComponent
125107
{...otherProps}
@@ -141,11 +123,6 @@ const View: React.AbstractComponent<
141123
style={style}
142124
// $FlowFixMe[incompatible-type]
143125
pointerEvents={newPointerEvents}
144-
// [macOS
145-
passthroughAllKeyEvents={_passthroughAllKeyEvents}
146-
validKeysDown={_validKeysDown}
147-
validKeysUp={_validKeysUp}
148-
// macOS]
149126
ref={forwardedRef}
150127
/>
151128
);

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ export interface ViewPropsAndroid {
166166
export type DraggedType = 'fileUrl';
167167
export type DraggedTypesType = DraggedType | DraggedType[];
168168

169+
export type HandledKeyboardEvent = {
170+
altKey?: boolean | undefined;
171+
ctrlKey?: boolean | undefined;
172+
metaKey?: boolean | undefined;
173+
shiftKey?: boolean | undefined;
174+
key: string;
175+
};
176+
169177
export interface ViewPropsMacOS {
170178
acceptsFirstMouse?: boolean | undefined;
171179
allowsVibrancy?: boolean | undefined;
@@ -178,11 +186,8 @@ export interface ViewPropsMacOS {
178186
onDrop?: ((event: MouseEvent) => void) | undefined;
179187
onKeyDown?: ((event: KeyEvent) => void) | undefined;
180188
onKeyUp?: ((event: KeyEvent) => void) | undefined;
181-
validKeysDown?: Array<HandledKeyEvent | string> | undefined;
182-
validKeysUp?: Array<HandledKeyEvent | string> | undefined;
183-
passthroughAllKeyEvents?: boolean | undefined;
184-
keyDownEvents?: Array<HandledKeyEvent> | undefined;
185-
keyUpEvents?: Array<HandledKeyEvent> | undefined;
189+
keyDownEvents?: HandledKeyboardEvent[] | undefined;
190+
keyUpEvents?: HandledKeyboardEvent[] | undefined;
186191
draggedTypes?: DraggedTypesType | undefined;
187192
}
188193

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

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ type DirectEventProps = $ReadOnly<{|
101101

102102
// [macOS
103103
/**
104-
* Represents a key that could be passed to `validKeysDown` and `validKeysUp`.
104+
* Represents a key that could be passed to `keyDownEvents` and `keyUpEvents`.
105105
*
106106
* `key` is the actual key, such as "a", or one of the special values:
107107
* "Tab", "Escape", "Enter", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
@@ -135,36 +135,10 @@ export type KeyboardEventProps = $ReadOnly<{|
135135
*
136136
* @platform macos
137137
*/
138-
validKeysDown?: ?Array<string | HandledKeyboardEvent>,
139-
140-
/**
141-
* Array of keys to receive key up events for. These events have their default native behavior prevented.
142-
*
143-
* @platform macos
144-
*/
145-
validKeysUp?: ?Array<string | HandledKeyboardEvent>,
146-
147-
/**
148-
* @deprecated use `keyDownEvents` or `keyUpEvents` instead
149-
* When `true`, allows `onKeyDown` and `onKeyUp` to receive events not specified in
150-
* `validKeysDown` and `validKeysUp`, respectively. Events matching `validKeysDown` and `validKeysUp`
151-
* are still removed from the event queue, but the others are not.
152-
*
153-
* @platform macos
154-
*/
155-
passthroughAllKeyEvents?: ?boolean,
156-
157-
/**
158-
* Array of keys to receive key down events for. These events have their default native behavior prevented.
159-
* Overrides the props `validKeysDown`, `validKeysUp` and `passthroughAllKeyEvents`
160-
*
161-
* @platform macos
162-
*/
163138
keyDownEvents?: ?Array<HandledKeyboardEvent>,
164139

165140
/**
166141
* Array of keys to receive key up events for. These events have their default native behavior prevented.
167-
* Overrides the props `validKeysDown`, `validKeysUp` and `passthroughAllKeyEvents`
168142
*
169143
* @platform macos
170144
*/

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;

0 commit comments

Comments
 (0)