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

Pull in upstream fixes to expose hover props on Pressable #884

Merged
merged 21 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c2b2e2f
add pull yml
Saadnajmi Mar 22, 2021
ab88c7d
Merge pull request #1 from microsoft/master
Saadnajmi Apr 2, 2021
7a9006b
match handleOpenURLNotification event payload with iOS (#755) (#2)
pull[bot] Apr 21, 2021
497aa72
Merge pull request #3 from microsoft/master
Saadnajmi Apr 28, 2021
1c81e5b
Merge pull request #4 from microsoft/master
Saadnajmi May 6, 2021
28aed35
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi May 20, 2021
62dc473
Merge branch 'master' of github.com:Saadnajmi/react-native-macos
Saadnajmi May 20, 2021
93c7296
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi May 21, 2021
780b2b7
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi Jun 11, 2021
99d5182
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi Aug 22, 2021
09e872d
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi Sep 3, 2021
9a25530
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi Oct 6, 2021
d82a01b
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi Oct 12, 2021
d9faa3a
[pull] master from microsoft:master (#11)
pull[bot] Oct 14, 2021
39bd488
Merge branch 'master' of github.com:microsoft/react-native-macos
Saadnajmi Oct 21, 2021
0818f75
Expose Pressability Hover config props in Pressable (#32405)
Saadnajmi Oct 26, 2021
718c3f2
Extra followup changes
Saadnajmi Nov 4, 2021
425569a
remove some extra fork differences from change
Saadnajmi Nov 4, 2021
58a6463
Add back type
Saadnajmi Nov 7, 2021
a23a1f1
update podfile
Saadnajmi Nov 7, 2021
02d8438
Merge branch 'master' of github.com:microsoft/react-native-macos into…
Saadnajmi Dec 7, 2021
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
44 changes: 33 additions & 11 deletions Libraries/Components/Pressable/Pressable.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ import type {
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
import usePressability from '../../Pressability/usePressability';
import {normalizeRect, type RectOrSize} from '../../StyleSheet/Rect';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {
LayoutEvent,
MouseEvent, // TODO(macOS GH#774)
MouseEvent,
PressEvent,
} from '../../Types/CoreEventTypes';
import type {DraggedTypesType} from '../View/DraggedType'; // TODO(macOS GH#774)
import View from '../View/View';

type ViewStyleProp = $ElementType<React.ElementConfig<typeof View>, 'style'>;
Expand Down Expand Up @@ -65,6 +63,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 +99,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 @@ -146,8 +164,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 @@ -167,11 +183,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 Down Expand Up @@ -208,10 +226,12 @@ function Pressable(props: Props, forwardedRef): React.Node {
hitSlop,
pressRectOffset: pressRetentionOffset,
android_disableSound,
delayHoverIn,
delayHoverOut,
delayLongPress,
delayPressIn: unstable_pressDelay,
onHoverIn: onMouseEnter, // [TODO(macOS GH#774)
onHoverOut: onMouseLeave, // ]TODO(macOS GH#774)
onHoverIn,
onHoverOut,
onLongPress,
onPress,
onPressIn(event: PressEvent): void {
Expand All @@ -237,11 +257,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
4 changes: 2 additions & 2 deletions packages/rn-tester/js/examples/Pressable/PressableExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ function PressableFeedbackEvents() {
testID="pressable_feedback_events_button"
accessibilityLabel="pressable feedback events"
accessibilityRole="button"
onMouseEnter={() => appendEvent('mouseEnter')} // [TODO(macOS GH#774)
onMouseLeave={() => appendEvent('mouseLeave')} // ]TODO(macOS GH#774)
onHoverIn={() => appendEvent('hoverIn')} // [TODO(macOS GH#774)
onHoverOut={() => appendEvent('hoverOut')} // ]TODO(macOS GH#774)
onPress={() => appendEvent('press')}
onPressIn={() => appendEvent('pressIn')}
onPressOut={() => appendEvent('pressOut')}
Expand Down