Skip to content

Commit f8e26e3

Browse files
Saadnajmipull[bot]ryanlntnntremganandraj
authored
Pull in upstream fixes to expose hover props on Pressable (#884)
* add pull yml * match handleOpenURLNotification event payload with iOS (#755) (#2) Co-authored-by: Ryan Linton <[email protected]> * [pull] master from microsoft:master (#11) * Deprecated api (#853) * Remove deprecated/unused context param * Update a few Mac deprecated APIs * Packing RN dependencies, hermes and ignoring javadoc failure, (#852) * Ignore javadoc failure * Bringing few more changes from 0.63-stable * Fixing a patch in engine selection * Fixing a patch in nuget spec * Fixing the output directory of nuget pack * Packaging dependencies in the nuget * Fix onMouseEnter/onMouseLeave callbacks not firing on Pressable (#855) * add pull yml * match handleOpenURLNotification event payload with iOS (#755) (#2) Co-authored-by: Ryan Linton <[email protected]> * fix mouse evetns on pressable * delete extra yml from this branch * Add macOS tags * reorder props to have onMouseEnter/onMouseLeave always be before onPress Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: Ryan Linton <[email protected]> * Grammar fixes. (#856) Updates simple grammar issues. Co-authored-by: Nick Trescases <[email protected]> Co-authored-by: Anandraj <[email protected]> Co-authored-by: Saad Najmi <[email protected]> Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: Ryan Linton <[email protected]> Co-authored-by: Muhammad Hamza Zaman <[email protected]> * Expose Pressability Hover config props in Pressable (facebook#32405) Summary: Several desktop forks (`react-native-macos`, `react-native-windows`, `react-native-web`) support mouse events, and while the stock Pressable component has the ability to support mouse events, it seems we aren't forwarding some props properly from Pressable -> Pressability. Pressability will calculate onMouseEnter / onMouseLeave event handlers based on the `onHoverIn/onHoverOut` callbacks passed into PressabilityConfig. https://github.com/facebook/react-native/blob/ad0d4534a751ed05f84ff971714c8f7a4d1deb3a/Libraries/Pressability/Pressability.js#L552 However, Pressable does not pass take in onHoverIn/onHoverOut props to pass to PressabilityConfig, so we can't take advantage of this functionality. This change should simply address that by passing the props through. <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [General] [Fixed] - Pressabel not passing hover props and event handlers to PressabilityConfig Pull Request resolved: facebook#32405 Test Plan: I fixed a similar issue in `react-native-macos` that I am now trying to contribute back upstream. #855 Reviewed By: yungsters Differential Revision: D31667737 Pulled By: sota000 fbshipit-source-id: f0bbe48302703bb2c45280d2afeec8d7a4586b6a * Extra followup changes * remove some extra fork differences from change * Add back type * update podfile Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: Ryan Linton <[email protected]> Co-authored-by: Nick Trescases <[email protected]> Co-authored-by: Anandraj <[email protected]> Co-authored-by: Muhammad Hamza Zaman <[email protected]>
1 parent f88f01a commit f8e26e3

File tree

3 files changed

+64
-41
lines changed

3 files changed

+64
-41
lines changed

Libraries/Components/Pressable/Pressable.js

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ import type {
2525
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
2626
import usePressability from '../../Pressability/usePressability';
2727
import {normalizeRect, type RectOrSize} from '../../StyleSheet/Rect';
28-
import type {ColorValue} from '../../StyleSheet/StyleSheet';
2928
import type {
3029
LayoutEvent,
31-
MouseEvent, // TODO(macOS GH#774)
30+
MouseEvent,
3231
PressEvent,
3332
} from '../../Types/CoreEventTypes';
3433
import type {DraggedTypesType} from '../View/DraggedType'; // TODO(macOS GH#774)
@@ -65,6 +64,16 @@ type Props = $ReadOnly<{|
6564
*/
6665
children: React.Node | ((state: StateCallbackType) => React.Node),
6766

67+
/**
68+
* Duration to wait after hover in before calling `onHoverIn`.
69+
*/
70+
delayHoverIn?: ?number,
71+
72+
/**
73+
* Duration to wait after hover out before calling `onHoverOut`.
74+
*/
75+
delayHoverOut?: ?number,
76+
6877
/**
6978
* Duration (in milliseconds) from `onPressIn` before `onLongPress` is called.
7079
*/
@@ -91,6 +100,16 @@ type Props = $ReadOnly<{|
91100
*/
92101
onLayout?: ?(event: LayoutEvent) => void,
93102

103+
/**
104+
* Called when the hover is activated to provide visual feedback.
105+
*/
106+
onHoverIn?: ?(event: MouseEvent) => mixed,
107+
108+
/**
109+
* Called when the hover is deactivated to undo visual feedback.
110+
*/
111+
onHoverOut?: ?(event: MouseEvent) => mixed,
112+
94113
/**
95114
* Called when a long-tap gesture is detected.
96115
*/
@@ -146,8 +165,6 @@ type Props = $ReadOnly<{|
146165
acceptsFirstMouse?: ?boolean,
147166
enableFocusRing?: ?boolean,
148167
tooltip?: ?string,
149-
onMouseEnter?: (event: MouseEvent) => void,
150-
onMouseLeave?: (event: MouseEvent) => void,
151168
onDragEnter?: (event: MouseEvent) => void,
152169
onDragLeave?: (event: MouseEvent) => void,
153170
onDrop?: (event: MouseEvent) => void,
@@ -167,11 +184,13 @@ function Pressable(props: Props, forwardedRef): React.Node {
167184
android_disableSound,
168185
android_ripple,
169186
children,
187+
delayHoverIn,
188+
delayHoverOut,
170189
delayLongPress,
171190
disabled,
172191
focusable,
173-
onMouseEnter, // [TODO(macOS GH#774)
174-
onMouseLeave, // ]TODO(macOS GH#774)
192+
onHoverIn,
193+
onHoverOut,
175194
onLongPress,
176195
onPress,
177196
onPressIn,
@@ -208,10 +227,12 @@ function Pressable(props: Props, forwardedRef): React.Node {
208227
hitSlop,
209228
pressRectOffset: pressRetentionOffset,
210229
android_disableSound,
230+
delayHoverIn,
231+
delayHoverOut,
211232
delayLongPress,
212233
delayPressIn: unstable_pressDelay,
213-
onHoverIn: onMouseEnter, // [TODO(macOS GH#774)
214-
onHoverOut: onMouseLeave, // ]TODO(macOS GH#774)
234+
onHoverIn,
235+
onHoverOut,
215236
onLongPress,
216237
onPress,
217238
onPressIn(event: PressEvent): void {
@@ -237,11 +258,13 @@ function Pressable(props: Props, forwardedRef): React.Node {
237258
[
238259
android_disableSound,
239260
android_rippleConfig,
261+
delayHoverIn,
262+
delayHoverOut,
240263
delayLongPress,
241264
disabled,
242265
hitSlop,
243-
onMouseEnter, // [TODO(macOS GH#774)
244-
onMouseLeave, // ]TODO(macOS GH#774)
266+
onHoverIn,
267+
onHoverOut,
245268
onLongPress,
246269
onPress,
247270
onPressIn,

packages/rn-tester/Podfile.lock

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,8 @@ SPEC CHECKSUMS:
510510
CocoaAsyncSocket: 694058e7c0ed05a9e217d1b3c7ded962f4180845
511511
CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f
512512
DoubleConversion: 0ea4559a49682230337df966e735d6cc7760108e
513-
FBLazyVector: 2cd8b2450a7de278408f5be1467889e90a08f258
514-
FBReactNativeSpec: 02b76af7d3c9034135e4d9d94293bf768752d250
513+
FBLazyVector: 51cc83402f3d709f74795ff5c422a3d64aad2d5c
514+
FBReactNativeSpec: 3a039b4dcabf30506715ca5c18c30d31d6c3e771
515515
Flipper: be611d4b742d8c87fbae2ca5f44603a02539e365
516516
Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41
517517
Flipper-Folly: e4493b013c02d9347d5e0cb4d128680239f6c78a
@@ -522,35 +522,35 @@ SPEC CHECKSUMS:
522522
glog: 0dc7efada961c0793012970b60faebbd58b0decb
523523
OpenSSL-Universal: ff34003318d5e1163e9529b08470708e389ffcdd
524524
RCT-Folly: b3998425a8ee9f695f57a204dc494534246f0fe9
525-
RCTRequired: a3bd1751e9cf0e38d20f3cbb929942bba696f228
526-
RCTTypeSafety: 9026992c34211be11abe388a656b8293c34ca51d
527-
React: bbd3a9e2b0249733cbe9ad7acfaf8a76518d2bc3
528-
React-callinvoker: 47411c997957069224b8dab7c54df4120761609c
529-
React-Core: 4aed02f28118c924e2ed70fa7986bd972e968375
530-
React-CoreModules: caf07250a9edfc74023809086c87b20e85b02c39
531-
React-cxxreact: 7c446b2022686f641f436c85ce3f150db8af2673
532-
React-jsi: c5d9184708894542c535b444e140def931175718
533-
React-jsiexecutor: 5d2ee18b3edcc35465d0bda5792d78d914b3db36
534-
React-jsinspector: 811d62cd7cda93f2e20455ce01d145318daad54f
535-
React-perflogger: b3498f7e34f9a4d17f894c2881bae1a09c0f0244
536-
React-RCTActionSheet: a64e3b4f8443fbb7fa521f0c5c5d12ef32ca7333
537-
React-RCTAnimation: 8d43053e147b2a03a0dd814b29fdee7400812db2
538-
React-RCTBlob: b085c43bf4c3e6666249b8b3e1059c81e4b0e4da
539-
React-RCTImage: c31b49d6fa0aca5f0d156689faf812f2fcbe327d
540-
React-RCTLinking: 0f37717500127be6ade174ee0e90b1c2e030812b
541-
React-RCTNetwork: 4436de92dd6069a955762d0b236824549e9c181c
542-
React-RCTPushNotification: 4214b15df86eb9ca37a755213b0492e94b8e25ac
543-
React-RCTSettings: 41666d59dd7f3f4b83308bc529cbd2885b8198ee
544-
React-RCTTest: 9d497d39f71774fdceb5636872a31ea8cf6299c4
545-
React-RCTText: b6d0d3b2b4e3ea50682364d018343cd9816d457f
546-
React-RCTVibration: d99e0b8f6b7c501259d277d4439e57098bccb7c5
547-
React-runtimeexecutor: 1c02384ab067ef628535c5ea9fea5237bdd63c0a
525+
RCTRequired: 2d686a7dce047f5d49d3cfaaafcac309faabdfa3
526+
RCTTypeSafety: 381a24d058ab4456271b44774bb2b13bffe73fe4
527+
React: c057844fd06ecfa863cfb9c84991ab0f486540f3
528+
React-callinvoker: 488e8d69e0eb35579dc5ef2b36efd4aa1a94f40b
529+
React-Core: 7260200dfa2667c56ed4cc27265c1e57d5d040fd
530+
React-CoreModules: 1a58a4fbe3a667760e0921a85c5da21492fb7715
531+
React-cxxreact: 1e319bcd17b54b6768c10b8b9e89397f153d7f87
532+
React-jsi: a4a24e1ea3874772a28eaef6124b17fad1a29e41
533+
React-jsiexecutor: 332bca23c317135ea722ab7bdd1f65b61be13a0f
534+
React-jsinspector: b1cb2f7a601f8aed95928062b908deddf3c82a48
535+
React-perflogger: 983acb8318ed9b7e9a7d0e1054218eaa24dfebe7
536+
React-RCTActionSheet: 83604ec93778a3b52805862d6feef63466765888
537+
React-RCTAnimation: 510927e07ee1e22b6a8ccbc7736df3105312c4cc
538+
React-RCTBlob: eb1e62da8269a1acb2a48edfa36c872b79dda27a
539+
React-RCTImage: e21d4e5881383144983a76fea1aa572b411f5d3e
540+
React-RCTLinking: 793a4b3843b04c4e6f63c491cb114b24c17a8e5c
541+
React-RCTNetwork: 7efd214d99d4e79d4ddabe76d2e01449267303d2
542+
React-RCTPushNotification: a4c94a936589b9b01ae6bc403b4b126f0ab64790
543+
React-RCTSettings: fe346a2cb5a0f73781b4430df3cba4ddeef9bafc
544+
React-RCTTest: a75eb8f43f21d1b6429e081945447accdd7047f0
545+
React-RCTText: 38b52e9a804c7f5c5197f8f59cfc64295af63e38
546+
React-RCTVibration: dcb108280be8bf84c1ab716348587ffce989a40d
547+
React-runtimeexecutor: fa0f514ab1020dbde36e9c88512930ceedb9bb2b
548548
React-TurboModuleCxx-RNW: 12172bdbaaf052406ec571465243fad4b2eb2702
549-
React-TurboModuleCxx-WinRTPort: ecb3b6ab042309397cb7473c7d6de5b62f918c0b
550-
ReactCommon: 70e4686a26373df89f82a55f093f393d225ae10a
551-
Yoga: 4eb93eb55b6973947ed8e71bb82c1dfaa849bd4c
549+
React-TurboModuleCxx-WinRTPort: 3844727e8cd53c024b276029bd96e01358d702e8
550+
ReactCommon: 94a1371a376fb197ff69b52efef86dc19d627abb
551+
Yoga: 28f20bff355b99c1d8bc07008f47546796859a1d
552552
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
553553

554554
PODFILE CHECKSUM: 096cbc796e89167c003b0c49186597432f0fb5e8
555555

556-
COCOAPODS: 1.10.2
556+
COCOAPODS: 1.11.2

packages/rn-tester/js/examples/Pressable/PressableExample.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ function PressableFeedbackEvents() {
9999
testID="pressable_feedback_events_button"
100100
accessibilityLabel="pressable feedback events"
101101
accessibilityRole="button"
102-
onMouseEnter={() => appendEvent('mouseEnter')} // [TODO(macOS GH#774)
103-
onMouseLeave={() => appendEvent('mouseLeave')} // ]TODO(macOS GH#774)
102+
onHoverIn={() => appendEvent('hoverIn')} // [TODO(macOS GH#774)
103+
onHoverOut={() => appendEvent('hoverOut')} // ]TODO(macOS GH#774)
104104
onPress={() => appendEvent('press')}
105105
onPressIn={() => appendEvent('pressIn')}
106106
onPressOut={() => appendEvent('pressOut')}

0 commit comments

Comments
 (0)