Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.63] Pull in upstream fixes to expose hover props on Pressable #884 #887

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 33 additions & 9 deletions Libraries/Components/Pressable/Pressable.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {normalizeRect, type RectOrSize} from '../../StyleSheet/Rect';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {
LayoutEvent,
MouseEvent, // TODO(macOS ISS#2323203)
MouseEvent,
PressEvent,
} from '../../Types/CoreEventTypes';
import type {DraggedTypesType} from '../View/DraggedType'; // TODO(macOS ISS#2323203)
Expand Down Expand Up @@ -65,6 +65,16 @@ type Props = $ReadOnly<{|
*/
children: React.Node | ((state: StateCallbackType) => React.Node),

/**
* Duration to wait after hover in before calling `onHoverIn`.
*/
delayHoverIn?: ?number,

/**
* Duration to wait after hover out before calling `onHoverOut`.
*/
delayHoverOut?: ?number,

/**
* Duration (in milliseconds) from `onPressIn` before `onLongPress` is called.
*/
Expand All @@ -91,6 +101,16 @@ type Props = $ReadOnly<{|
*/
onLayout?: ?(event: LayoutEvent) => void,

/**
* Called when the hover is activated to provide visual feedback.
*/
onHoverIn?: ?(event: MouseEvent) => mixed,

/**
* Called when the hover is deactivated to undo visual feedback.
*/
onHoverOut?: ?(event: MouseEvent) => mixed,

/**
* Called when a long-tap gesture is detected.
*/
Expand Down Expand Up @@ -141,8 +161,6 @@ type Props = $ReadOnly<{|
acceptsFirstMouse?: ?boolean,
enableFocusRing?: ?boolean,
tooltip?: ?string,
onMouseEnter?: (event: MouseEvent) => void,
onMouseLeave?: (event: MouseEvent) => void,
onDragEnter?: (event: MouseEvent) => void,
onDragLeave?: (event: MouseEvent) => void,
onDrop?: (event: MouseEvent) => void,
Expand All @@ -162,11 +180,13 @@ function Pressable(props: Props, forwardedRef): React.Node {
android_disableSound,
android_ripple,
children,
delayHoverIn,
delayHoverOut,
delayLongPress,
disabled,
focusable,
onMouseEnter, // [TODO(macOS GH#774)
onMouseLeave, // ]TODO(macOS GH#774)
onHoverIn,
onHoverOut,
onLongPress,
onPress,
onPressIn,
Expand All @@ -192,9 +212,11 @@ function Pressable(props: Props, forwardedRef): React.Node {
hitSlop,
pressRectOffset: pressRetentionOffset,
android_disableSound,
delayHoverIn,
delayHoverOut,
delayLongPress,
onHoverIn: onMouseEnter, // [TODO(macOS GH#774)
onHoverOut: onMouseLeave, // ]TODO(macOS GH#774)
onHoverIn,
onHoverOut,
onLongPress,
onPress,
onPressIn(event: PressEvent): void {
Expand All @@ -220,11 +242,13 @@ function Pressable(props: Props, forwardedRef): React.Node {
[
android_disableSound,
android_rippleConfig,
delayHoverIn,
delayHoverOut,
delayLongPress,
disabled,
hitSlop,
onMouseEnter, // [TODO(macOS GH#774)
onMouseLeave, // ]TODO(macOS GH#774)
onHoverIn,
onHoverOut,
onLongPress,
onPress,
onPressIn,
Expand Down
Loading