Skip to content

Commit a19090d

Browse files
authored
Remove unnecessary overrides to onFocus and onBlur in Pressable (#10942)
* Remove unneccesary overrides * Change files * Add test
1 parent 9e22298 commit a19090d

File tree

5 files changed

+16
-40
lines changed

5 files changed

+16
-40
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Remove unnecessary overrides to onFocus and onBlur in Pressable",
4+
"packageName": "@office-iss/react-native-win32",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Remove unnecessary overrides to onFocus and onBlur in Pressable",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/@office-iss/react-native-win32/src/Libraries/Components/Pressable/Pressable.win32.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -289,22 +289,6 @@ function Pressable(props: Props, forwardedRef): React.Node {
289289
const viewRef = useRef<React.ElementRef<typeof View> | null>(null);
290290
useImperativeHandle(forwardedRef, () => viewRef.current);
291291

292-
// [Windows
293-
const _onBlur = (event: BlurEvent) => {
294-
TextInputState.blurInput(viewRef.current);
295-
if (props.onBlur) {
296-
props.onBlur(event);
297-
}
298-
};
299-
300-
const _onFocus = (event: FocusEvent) => {
301-
TextInputState.focusInput(viewRef.current);
302-
if (props.onFocus) {
303-
props.onFocus(event);
304-
}
305-
};
306-
// Windows]
307-
308292
const android_rippleConfig = useAndroidRippleForView(android_ripple, viewRef);
309293

310294
const [pressed, setPressed] = usePressState(testOnly_pressed === true);
@@ -418,10 +402,6 @@ function Pressable(props: Props, forwardedRef): React.Node {
418402
<View
419403
{...restPropsWithDefaults}
420404
{...eventHandlers}
421-
// [Windows
422-
onBlur={_onBlur}
423-
onFocus={_onFocus}
424-
// Windows]
425405
ref={viewRef}
426406
style={typeof style === 'function' ? style({pressed}) : style}>
427407
{typeof children === 'function' ? children({pressed}) : children}

packages/@react-native-windows/tester/src/js/examples/Pressable/PressableExample.windows.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ function PressableFeedbackEvents() {
121121
accessibilityLabel="pressable feedback events"
122122
accessibilityRole="button"
123123
// [Windows
124+
onFocus={() => appendEvent('focus')}
125+
onBlur={() => appendEvent('blur')}
124126
onHoverIn={() => appendEvent('hover in')}
125127
onHoverOut={() => appendEvent('hover out')}
126128
// Windows]

vnext/src/Libraries/Components/Pressable/Pressable.windows.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -289,22 +289,6 @@ function Pressable(props: Props, forwardedRef): React.Node {
289289
const viewRef = useRef<React.ElementRef<typeof View> | null>(null);
290290
useImperativeHandle(forwardedRef, () => viewRef.current);
291291

292-
// [Windows
293-
const _onBlur = (event: BlurEvent) => {
294-
TextInputState.blurInput(viewRef.current);
295-
if (props.onBlur) {
296-
props.onBlur(event);
297-
}
298-
};
299-
300-
const _onFocus = (event: FocusEvent) => {
301-
TextInputState.focusInput(viewRef.current);
302-
if (props.onFocus) {
303-
props.onFocus(event);
304-
}
305-
};
306-
// Windows]
307-
308292
const android_rippleConfig = useAndroidRippleForView(android_ripple, viewRef);
309293

310294
const [pressed, setPressed] = usePressState(testOnly_pressed === true);
@@ -418,10 +402,6 @@ function Pressable(props: Props, forwardedRef): React.Node {
418402
<View
419403
{...restPropsWithDefaults}
420404
{...eventHandlers}
421-
// [Windows
422-
onBlur={_onBlur}
423-
onFocus={_onFocus}
424-
// Windows]
425405
ref={viewRef}
426406
style={typeof style === 'function' ? style({pressed}) : style}>
427407
{typeof children === 'function' ? children({pressed}) : children}

0 commit comments

Comments
 (0)