Fix onPointerLeave computation by comparing button presses #50402
+57
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
While investigating pointer events, I noticed that all Android views fire
onPointerLeave
/onPointerEnter
in rapid succession on every button press. This is because Android firesACTION_HOVER_EXIT
on every frame before firingACTION_DOWN
. The logic in JSPointerDispatcher needed to be updated to account for this.Unfortunately,
ACTION_HOVER_EXIT
events have no means of distinguishing between whether they were driven by the mouse actually leaving the view's bounds or by a button press. Some OS implementations fire this event on the frame just before leaving the view's boundaries while others fire after, so pure X/Y position isn't helpful enough. The button state property onACTION_HOVER_EXIT
also never gets set in some OS.To work around this issue, this change posts a callback to the very next frame after receiving
ACTION_HOVER_EXIT
. If noACTION_DOWN
event was received in the same frame, it calls all the way through the existing logic. But, if anACTION_DOWN
event is received, we compare the event timestamps and if they match we don't postonPointerLeave
.Changelog: [Android][Fixed] - Prevent onPointerLeave from dispatching during button presses
Differential Revision: D72078450