[Flare] Ensure mouse events can use target to validate press #16172
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.
This PR fixes an interesting bug that we encountered internally using the
Press
responder. When using mouse events (via pointer events or mouse events), we have a guarantee that the event target will be that of the one we're moving/releasing from (unlike touch events, which can have the same target as when the press was initiated). This mechanic for mouse events lets us bypass thegetBoundingClientRect
logic, which is:responderTarget
are absolutely positionedwidth
and/orheight
as0
when some CSS styles are appliedThis behaviour already existed in the current Press implementation. But there were two bugs:
isTargetWithinNode
wasn't taking into account thealternate
fiberisPressWithinResponderRegion
totrue
if we knew the mouse event target was in the responder region (by using the targets).This fixes both cases, which also fixes the internal bug we were seeing.