Commit Graph

35 Commits

Author SHA1 Message Date
Tim Yung 1977dd6596 RN: Sort Pragmas in Headers (#51554)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51554

Sorts pragma directives file headers in React Native.

Changelog:
[Internal]

Reviewed By: SamChou19815

Differential Revision: D75264593

fbshipit-source-id: 9e4b253dd0fc94dc2fc469d7114b93a8aae305f4
2025-05-22 21:18:53 -07:00
Tim Yung 00108a1ac3 RN: Prefer Destructured Import for useState (#51403)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51403

Prefers using this as a destructured import instead of as a member expression of `React`.

Changelog:
[Internal]

Reviewed By: SamChou19815

Differential Revision: D74891875

fbshipit-source-id: 981e85b5da84950c9e66e8d6b6496019e536711d
2025-05-16 16:33:18 -07:00
Sam Zhou 723a37cb26 Replace most of the remaining React.AbstractComponent in react-native (#47143)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47143

In order to adopt react 19's ref-as-prop model, we need to eliminate all the places where they are treated differently. `React.AbstractComponent` is the worst example of this, and we need to eliminate it.

This diff replaces most of the remaining `React.AbstractComponent` in react-native.

Changelog: [Internal]

Reviewed By: alexmckenley

Differential Revision: D64701145

fbshipit-source-id: c765674fdf59812895c4fae43df97cf8b9d24f05
2024-10-21 15:48:25 -07:00
Moti Zilberman d6e0bc714a Enable lint/sort-imports everywhere (#41334)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41334

TSIA.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D51025812

fbshipit-source-id: e10d437be775a6b80946483aa96460f34927f870
2023-11-06 12:59:38 -08:00
Gijs Weterings 67c1a806e6 Flow strictify xplat/js/react-native-github where possible (#41051)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41051

Strictifies flow to flow strict-local in files where doing that doesn't cause new flow errors.

Changelog: Internal

Reviewed By: yungsters

Differential Revision: D50369011

fbshipit-source-id: b4a5a26b839b7327a3178e6f5b35246dea365a38
2023-10-18 05:36:33 -07:00
Vincent Riemer 001e182f08 Add PointerEventCaptureMouse WPT test (#37603)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37603

Changelog: [Internal] - Add PointerEventCaptureMouse WPT test

This diff introduces a port of the wpt test "pointerevent_capture_mouse" (https://github.com/web-platform-tests/wpt/blob/master/pointerevents/pointerevent_capture_mouse.html) in preparation of validating our pointer capture implementation.

Reviewed By: adanoff

Differential Revision: D46230497

fbshipit-source-id: ebdfaad23935b96d35da98e30bd326ae1b50759a
2023-06-12 19:27:14 -07:00
Alex Danoff 3a9b8748ac W3CPointerEvents: add basic testbed for click event accessibility (#37540)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37540

Changelog: [Internal] [Added] - W3CPointerEvents: add basic testbed for click event accessibility

This change adds a test bed with some nested pressables/clickable views. We can use this to test behavior for accessibility clicks on nested pressables (a corner case), and this can be expanded for other a11y testing in the future.

Reviewed By: NickGerleman

Differential Revision: D46081730

fbshipit-source-id: 6a9e1d52b2d8824cd61cb32dd0da435499c4ef29
2023-05-24 10:16:15 -07:00
Alex Danoff 670fa88327 W3CPointerEvents: add tests for click event (#37538)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37538

Changelog: [Internal] - W3CPointerEvents: add tests for click event

We don't have any existing tests which exercise the new (PointerEvent-based) click events. This change adds 3 tests:

1. PointerEventClickTouch: checks that the click event fires on an element when it is touched and released, and verifies that the event properties have the expected values
2. PointerEventClickTouchHierarchy: checks that the click event fires appropriately in a hierarchy of elements when the initial target of the touch is not the same as the final target (i.e. where the touch is released)
3. PointerEventClickTouchHierarchyPointerEvents: checks that the click event respects the setting of `pointerEvents` property in a hierarchy of elements

Note: these tests currently fail (at least on Android); future changes will bring the functionality in line with test expectations.

Reviewed By: vincentriemer

Differential Revision: D45121367

fbshipit-source-id: 7f22ea582e2568c418f569b7e1139388593574ab
2023-05-23 15:25:40 -07:00
Alex Danoff a27270f492 W3CPointerEvents: use description to indicate HW requirements for tests (#36840)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36840

Changelog: [Internal] - W3CPointerEvents: use description to indicate HW requirements for tests

As title. This lets users/testers know whether additional hardware is required to run each test and can give info on the test status (e.g. whether it's expected to fail). Tests with no description should be assumed to work without any special requirements.

Reviewed By: vincentriemer

Differential Revision: D44687709

fbshipit-source-id: 6a23344c4cce6917f3cf5cd3ada0c75b813b5abe
2023-04-06 13:06:10 -07:00
Vincent Riemer b2fda3eca7 Add platform test for pointercancel events caused by touch scrolling
Summary:
Changelog: [Internal] - Add platform test for pointercancel events caused by touch scrolling

This diff adds a new ported Web Platform Test which [verifies that pointercancel events are properly emitted once a touch causes scrolling](https://github.com/web-platform-tests/wpt/blob/master/pointerevents/pointerevent_pointercancel_touch.html).

Reviewed By: lunaleaps

Differential Revision: D43855277

fbshipit-source-id: 94a106058ba2c5e5fe4c1980519ceceddb2bb389
2023-03-16 12:23:25 -07:00
Luna Wei 8fbcb5cf94 RNTester: Number the WPT tests
Summary: Changelog: [Internal] Number WPT tests

Reviewed By: vincentriemer

Differential Revision: D42591932

fbshipit-source-id: 53d32692dc2fd2ec150e836b0ffb81cba87051ef
2023-01-20 15:16:28 -08:00
Vincent Riemer f5bd272a33 Add pointer event test ensuring that pointerover events are fired when an element appears under the cursor
Summary:
Changelog: [RNTester][Internal] - Add pointer event test ensuring that pointerover events are fired when an element appears under the cursor

This diff adds a port of an existing web platform test that checks if pointerover & pointerenter events are fired for elements that are mounted underneath the cursor.

Reviewed By: lunaleaps

Differential Revision: D40449499

fbshipit-source-id: 393f4325f7a9d9025fe9d0aab38642b1e3ab2612
2022-10-20 11:47:47 -07:00
Vincent Riemer 55fca7fd38 Add PointerOver/PointerOut handling test
Summary:
Changelog: [RNTester][Internal] - Add PointerOver/PointerOut handling test

This diff adds another platform test based on WPT testcase for mouseover/mouseout events but instead applied to pointerover/pointerout events recently implemented for RN.

Reviewed By: lunaleaps

Differential Revision: D40359286

fbshipit-source-id: 672f413f56faca55b9d838150fb66de66d78d6f2
2022-10-17 15:34:16 -07:00
Luna Wei 71ae987820 Prefix web platform tests with wpt
Summary:
Changelog: [Internal] Reorder and prefix things with wpt for convenience

Open to other suggestions

Reviewed By: mdvacca

Differential Revision: D40247488

fbshipit-source-id: 4046040d5904b324a9a84dc47f4de858456e7bbc
2022-10-14 15:10:19 -07:00
Luna Wei 68f3fb275f Add many pointers example
Summary: Changelog: [Internal] - Add a display example for offset of many pointers

Reviewed By: mdvacca

Differential Revision: D39736111

fbshipit-source-id: 1fb3f1037d7e743ae1a383a4f4ee876e32da4a6a
2022-10-13 18:05:55 -07:00
Vincent Riemer c48cb04ce4 Add pointerMove between platform test
Summary:
Changelog: [RNTester][Internal] - Add "PointerMove Between" platform test

This diff adds another port of a web platform test which verifies the event order when a hoverable pointer moves between elements.

Reviewed By: lunaleaps

Differential Revision: D40164303

fbshipit-source-id: 12f39dfcf7a1a4acabfd762185bc2227451b1057
2022-10-07 12:07:19 -07:00
Vincent Riemer 36c971695c Add pointer event pointer move event order test
Summary:
Changelog: [Internal] - Add pointer event pointer move event order test

This diff adds a port of the [mouse event mouse move event order test](https://github.com/web-platform-tests/wpt/blob/master/uievents/order-of-events/mouse-events/mouseevents-mousemove.html) but instead used here for testing our pointer event implementation.

Reviewed By: lunaleaps

Differential Revision: D40041387

fbshipit-source-id: 491659405865e1a0d95cfd1b3227a48a6136a98b
2022-10-05 16:06:18 -07:00
Vincent Riemer 93b51b5f86 Add MoveAcross test for pointer events
Summary:
Changelog: [RNTester][Internal] - Add "move across" test for pointer events

This diff adds a new platform test ported from the wpt's [mousemove-across test](https://github.com/web-platform-tests/wpt/blob/master/uievents/order-of-events/mouse-events/mousemove-across.html) along with a rough port of the wpt's event recorder class which is made to work in a react component environment.

Reviewed By: lunaleaps

Differential Revision: D39221252

fbshipit-source-id: 16b2e03dbc71a2e83cc43af1e950803feaf6657b
2022-09-12 14:48:39 -07:00
Luna Wei 5198d56f28 Stop sending PointerEvents when view is native gesture handling
Summary:
Changelog: [Internal] - Stop dispatching pointer events when a child view has indicated it wants to handle a native gesture.

In discussion and alignment with web standards, we've decided to not dispatch any pointer events during a native gesture.

Currently, on ACTION_HOVER_MOVE, we remove child views of the native gesture handling view and continue dispatching onPointerMove for ancestor views. This change removes this logic and won't dispatch a onPointerMove event at all.

For all other MotionEvent actions, this is already the case.

Also adding an example in RNTester that involves a scrollView (which handles gestures during scrolling)

Reviewed By: javache

Differential Revision: D39377157

fbshipit-source-id: cb0a719f67136e31b68d6f6e794fee10b256bf21
2022-09-12 12:17:21 -07:00
Vincent Riemer c89f5fdfd6 Rework button/buttons handling & add a new test checking for move events on chorded mouse button presses
Summary:
Changelog: [iOS][Internal] - Rework button/buttons handling on pointer events & add a new test checking for move events on chorded mouse button presses

This is a larger diff that largely stems from implementing a new pointer event platform test about chorded mouse button presses (adapted from https://github.com/web-platform-tests/wpt/blob/master/pointerevents/pointerevent_pointermove_on_chorded_mouse_button.html). In order to implement this test I added a new method, `step`, to an async test instance to allow you to run ad-hoc assertions labeled by the async test (like it's done in the original web platform test).

Once implementing the test I also discovered my current logic for handling the `button` and `buttons` properties was insufficient so I reworked it to handle more/most cases by making the `button` property instead determined by the change in the `buttons` property. This largely works but unfortunately due to what seems to be a bug in UIKit, chorded pointer "up" events receive the wrong button mask values so it's currently impossible to get this test fully passing on iOS. I've since submitted a bug report to Apple but my hopes aren't high that it will be focused on since it's such a niche issue.

Reviewed By: lunaleaps

Differential Revision: D38951159

fbshipit-source-id: 426b7cf7930ed8329151382fafee487493e568de
2022-09-01 15:01:33 -07:00
Luna Wei dfcd9faaad Add support for pointerover and pointerout
Summary: Changelog: [Internal] - Add pointerover, pointerout events

Reviewed By: vincentriemer

Differential Revision: D38559454

fbshipit-source-id: 829b9f2f22e1e41a64dcce80fcc79ab9e6352dcf
2022-08-15 12:51:58 -07:00
Vincent Riemer 647542c6c8 Add a pointer event attributes test variant for no-hover pointers
Summary:
Changelog: [RNTester][Internal] - Add a pointer event attributes test variant for no-hover pointers

This adds a slightly different version of the existing PointerEventAttributesHoverablePointers test but for pointers that cannot hover (such as touches)

Reviewed By: lunaleaps

Differential Revision: D38401888

fbshipit-source-id: 4ed782cc2157dcaa8f6c294ae3589843d020bc92
2022-08-09 16:37:56 -07:00
Vincent Riemer 546c4b4c6c Add isPrimary property implementation to the PointerEvent object
Summary:
Changelog: [iOS][Internal] - Add isPrimary property implementation to the PointerEvent object

This diff adds the `isPrimary` property to the PointerEvent object iOS implementation. In addition this adds a related change where we "reserve" the 0 touch identifier for mouse events and the 1 identifier for apple pencil events. This is an easy way to ensure that these pointers are always consistent no matter what happens. Since mouse & pencil pointers should always be considered the primary pointer, that allows us to focus the more advanced primary pointer differentiation purely on touch events.

The logic for this touch event primary pointer differentiation is essentially setting the first touch it recieves as a primary pointer, setting it on touch registration, and sets all subsequent touchs (while the first touch is down) as not the primary pointers. When that primary pointer is lifted, the class property keeping track of the primary pointer is reset and then the **next** pointer (secondary pointers which had already started before the previous primary pointer was lifted are not "upgraded" to primary) is marked as primary. A new platform test is also included in this diff in order to verify the aforementioned behavior.

Reviewed By: lunaleaps

Differential Revision: D37961707

fbshipit-source-id: ae8b78c5bfea6902fb73094fca1552e4e648ea44
2022-07-26 11:41:48 -07:00
Luna Wei 89f090016d Add a pointermove with AnimatedEvent example
Summary: Changelog: [Internal] - Add an example of pointermove using AnimatedEvent

Reviewed By: vincentriemer

Differential Revision: D37769263

fbshipit-source-id: 25de0ae88b55148d23fa388768707ea859e9ae4d
2022-07-13 15:45:45 -07:00
Luna Wei 4f522be373 - Add offsetX, offsetY values
Summary: Changelog: [Internal] Provide Android backing for offsetX, offsetY values.

Reviewed By: javache

Differential Revision: D37734498

fbshipit-source-id: f0f6daea3a2da27c79d42b9546eafa757ec448e7
2022-07-13 15:45:45 -07:00
Luna Wei 1753e7697d Fix: Ensure forms stacking context for events
Summary: Changelog: [Internal] - If any relevant view events (pointer, touch events, gesture responder, etc.) are declared on view, then the view must form stacking context. We need this change for pointer events specifically to determine whether we've entered/exited a view

Reviewed By: vincentriemer

Differential Revision: D37678352

fbshipit-source-id: 02641549ef608b1c9468ac693c7da629143212cb
2022-07-08 13:11:56 -07:00
Luna Wei 8be49e8746 PointerEvents: Remove '2' suffix
Summary: Changelog: [Internal] - We can now remove the '2' suffix as we had an internal implementation that was not truly aligned with W3C pointers but used the same name. We have aligned the internal types to match w3c so we can now remove the suffix that differentiates them.

Reviewed By: vincentriemer

Differential Revision: D37545813

fbshipit-source-id: 6f2336ae9e314066c340161113268c1f28621a71
2022-07-05 20:00:42 -07:00
Vincent Riemer fb57929f22 Add basic pointermove test to RNTester platform test suite
Summary: Changelog: [RNTester][Internal] - Add basic pointermove test to RNTester platform test suite

Reviewed By: lunaleaps

Differential Revision: D37324483

fbshipit-source-id: 5c2fdd8ef4bb38052966116e46d3cfdf6c525ee0
2022-06-24 12:00:44 -07:00
Pieter Vanderwerff e7a4dbcefc Add LTI annotations to function params in xplat/js [1/2]
Summary: Add annotations to function parameters required for Flow's Local Type Inference project. This codemod prepares the codebase to match Flow's new typechecking algorithm. The new algorithm will make Flow more reliable and predicatable.

Reviewed By: evanyeung

Differential Revision: D37353648

fbshipit-source-id: e5a0c685ced85a8ff353d578b373f836b376bb28
2022-06-22 21:36:52 -07:00
Vincent Riemer b2aa41578e Add basic platform testing framework for RNTester
Summary: Changelog: [RNTester][Internal] - Add experimental platform testing framework for RNTester

Reviewed By: lunaleaps, kacieb

Differential Revision: D36633708

fbshipit-source-id: 0f2f7642bc6db31e148a2a214c17fe39656612fd
2022-05-24 19:14:11 -07:00
Luna Wei 3369a29bda PointerEvents: RNTester make example easier to specify what events you want to listen to
Summary: Changelog: [Internal] - Make it easier to specify what events to listen to on each `EventfulView`. This is helpful for testing future optimizations to event dispatch filtering. Also removed the switches for triggering events -- the idea being that we're using these examples with Metro and we can just remove the relevant props when we want to not fire any events.

Reviewed By: kacieb

Differential Revision: D36530066

fbshipit-source-id: 3ff45c263bdcacedde8d2720e156ab8156424c53
2022-05-20 11:13:36 -07:00
Luna Wei de09bd3b84 Dispatch enter/leave for ancestor hit path
Summary: Changelog: [Internal] - Fix pointer event dispatch to also fire enter/leave for ancestors in the hit path. Compared the event order with web on the RNTester W3C pointer example

Reviewed By: appden

Differential Revision: D35403076

fbshipit-source-id: 726e45e49a901b1d97ad3e20f5898701fd1f763b
2022-04-11 17:17:10 -07:00
Pieter De Baets 6e5cefe604 Codemod arvr to use onPointer* instead of onEnter/onExit/onMove
Summary: Changelog: [Internal] Improve experimental support for pointer event dispatching support in JS

Reviewed By: mdvacca

Differential Revision: D35216647

fbshipit-source-id: 212f038115e4713097db05847a9638efe0a25bed
2022-04-05 07:11:10 -07:00
Luna Wei 4ce3914727 Add absolute child example to RNTester - W3CPointerEvents
Summary: Changelog: [Internal] Add another example for testing out the pointer events spec

Reviewed By: vincentriemer

Differential Revision: D35116565

fbshipit-source-id: 5f0cfeb871ae55071549c2289782401807f55515
2022-03-30 19:12:42 -07:00
Luna Wei 50070ec7c6 Add W3CPointerEvent example to RNTester Android
Summary:
Changelog: [Internal]
Add an example demonstrating pointer events

Reviewed By: vincentriemer

Differential Revision: D34422438

fbshipit-source-id: da378b4aaae8548f1114c1b23351527db6a6db69
2022-03-30 19:12:42 -07:00