Skip to content

Commit

Permalink
Remove unnecessary overrides to onFocus and onBlur in Pressable (#…
Browse files Browse the repository at this point in the history
…10942) (#11014)

* Remove unneccesary overrides

* Change files

* Add  test
  • Loading branch information
Saadnajmi committed Dec 15, 2022
1 parent 1574c5b commit ec85514
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 40 deletions.
@@ -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"
}
@@ -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"
}
Expand Up @@ -253,22 +253,6 @@ function Pressable(props: Props, forwardedRef): React.Node {
const viewRef = useRef<React.ElementRef<typeof View> | 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);
Expand Down Expand Up @@ -360,10 +344,6 @@ function Pressable(props: Props, forwardedRef): React.Node {
<View
{...restPropsWithDefaults}
{...eventHandlers}
// [Windows
onBlur={_onBlur}
onFocus={_onFocus}
// Windows]
ref={viewRef}
style={typeof style === 'function' ? style({pressed}) : style}>
{typeof children === 'function' ? children({pressed}) : children}
Expand Down
Expand Up @@ -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]
Expand Down
20 changes: 0 additions & 20 deletions vnext/src/Libraries/Components/Pressable/Pressable.windows.js
Expand Up @@ -253,22 +253,6 @@ function Pressable(props: Props, forwardedRef): React.Node {
const viewRef = useRef<React.ElementRef<typeof View> | 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);
Expand Down Expand Up @@ -360,10 +344,6 @@ function Pressable(props: Props, forwardedRef): React.Node {
<View
{...restPropsWithDefaults}
{...eventHandlers}
// [Windows
onBlur={_onBlur}
onFocus={_onFocus}
// Windows]
ref={viewRef}
style={typeof style === 'function' ? style({pressed}) : style}>
{typeof children === 'function' ? children({pressed}) : children}
Expand Down

0 comments on commit ec85514

Please sign in to comment.