From ec85514994876376e4f546446818c0621625eb97 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Thu, 15 Dec 2022 13:05:30 -0800 Subject: [PATCH] Remove unnecessary overrides to `onFocus` and `onBlur` in Pressable (#10942) (#11014) * Remove unneccesary overrides * Change files * Add test --- ...-d749cec8-efe8-47ab-86f3-2a7777738436.json | 7 +++++++ ...-d03682bc-a25c-4760-a5f6-c2f540cb8725.json | 7 +++++++ .../Components/Pressable/Pressable.win32.js | 20 ------------------- .../Pressable/PressableExample.windows.js | 2 ++ .../Components/Pressable/Pressable.windows.js | 20 ------------------- 5 files changed, 16 insertions(+), 40 deletions(-) create mode 100644 change/@office-iss-react-native-win32-d749cec8-efe8-47ab-86f3-2a7777738436.json create mode 100644 change/react-native-windows-d03682bc-a25c-4760-a5f6-c2f540cb8725.json diff --git a/change/@office-iss-react-native-win32-d749cec8-efe8-47ab-86f3-2a7777738436.json b/change/@office-iss-react-native-win32-d749cec8-efe8-47ab-86f3-2a7777738436.json new file mode 100644 index 00000000000..0b0cb9c4367 --- /dev/null +++ b/change/@office-iss-react-native-win32-d749cec8-efe8-47ab-86f3-2a7777738436.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Remove unnecessary overrides to onFocus and onBlur in Pressable", + "packageName": "@office-iss/react-native-win32", + "email": "sanajmi@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/react-native-windows-d03682bc-a25c-4760-a5f6-c2f540cb8725.json b/change/react-native-windows-d03682bc-a25c-4760-a5f6-c2f540cb8725.json new file mode 100644 index 00000000000..dd2fb9bf4fb --- /dev/null +++ b/change/react-native-windows-d03682bc-a25c-4760-a5f6-c2f540cb8725.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Remove unnecessary overrides to onFocus and onBlur in Pressable", + "packageName": "react-native-windows", + "email": "sanajmi@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/@office-iss/react-native-win32/src/Libraries/Components/Pressable/Pressable.win32.js b/packages/@office-iss/react-native-win32/src/Libraries/Components/Pressable/Pressable.win32.js index c70cb2b96fc..7fc84aa9c15 100644 --- a/packages/@office-iss/react-native-win32/src/Libraries/Components/Pressable/Pressable.win32.js +++ b/packages/@office-iss/react-native-win32/src/Libraries/Components/Pressable/Pressable.win32.js @@ -253,22 +253,6 @@ function Pressable(props: Props, forwardedRef): React.Node { const viewRef = useRef | null>(null); useImperativeHandle(forwardedRef, () => viewRef.current); - // [Windows - const _onBlur = (event: BlurEvent) => { - TextInputState.blurInput(viewRef.current); - if (props.onBlur) { - props.onBlur(event); - } - }; - - const _onFocus = (event: FocusEvent) => { - TextInputState.focusInput(viewRef.current); - if (props.onFocus) { - props.onFocus(event); - } - }; - // Windows] - const android_rippleConfig = useAndroidRippleForView(android_ripple, viewRef); const [pressed, setPressed] = usePressState(testOnly_pressed === true); @@ -360,10 +344,6 @@ function Pressable(props: Props, forwardedRef): React.Node { {typeof children === 'function' ? children({pressed}) : children} diff --git a/packages/@react-native-windows/tester/src/js/examples/Pressable/PressableExample.windows.js b/packages/@react-native-windows/tester/src/js/examples/Pressable/PressableExample.windows.js index 1835f67bb5a..9b6f2483b88 100644 --- a/packages/@react-native-windows/tester/src/js/examples/Pressable/PressableExample.windows.js +++ b/packages/@react-native-windows/tester/src/js/examples/Pressable/PressableExample.windows.js @@ -102,6 +102,8 @@ function PressableFeedbackEvents() { accessibilityLabel="pressable feedback events" accessibilityRole="button" // [Windows + onFocus={() => appendEvent('focus')} + onBlur={() => appendEvent('blur')} onHoverIn={() => appendEvent('hover in')} onHoverOut={() => appendEvent('hover out')} // Windows] diff --git a/vnext/src/Libraries/Components/Pressable/Pressable.windows.js b/vnext/src/Libraries/Components/Pressable/Pressable.windows.js index c70cb2b96fc..7fc84aa9c15 100644 --- a/vnext/src/Libraries/Components/Pressable/Pressable.windows.js +++ b/vnext/src/Libraries/Components/Pressable/Pressable.windows.js @@ -253,22 +253,6 @@ function Pressable(props: Props, forwardedRef): React.Node { const viewRef = useRef | null>(null); useImperativeHandle(forwardedRef, () => viewRef.current); - // [Windows - const _onBlur = (event: BlurEvent) => { - TextInputState.blurInput(viewRef.current); - if (props.onBlur) { - props.onBlur(event); - } - }; - - const _onFocus = (event: FocusEvent) => { - TextInputState.focusInput(viewRef.current); - if (props.onFocus) { - props.onFocus(event); - } - }; - // Windows] - const android_rippleConfig = useAndroidRippleForView(android_ripple, viewRef); const [pressed, setPressed] = usePressState(testOnly_pressed === true); @@ -360,10 +344,6 @@ function Pressable(props: Props, forwardedRef): React.Node { {typeof children === 'function' ? children({pressed}) : children}