Fix press gestures in portal windows#3666
Closed
iamEvanYT wants to merge 3 commits intomotiondivision:mainfrom
Closed
Fix press gestures in portal windows#3666iamEvanYT wants to merge 3 commits intomotiondivision:mainfrom
iamEvanYT wants to merge 3 commits intomotiondivision:mainfrom
Conversation
Greptile SummaryThis PR fixes press gestures for elements rendered into portal windows or iframes by resolving
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant E as Element (in iframe)
participant PH as press() handler
participant GEW as getEventTargetWindow()
participant IW as iframe.contentWindow
participant GW as global window (before fix)
Note over E,GW: Before fix
E->>PH: pointerdown
PH->>GW: addEventListener("pointerup", ...)
E-->>GW: pointerup never arrives (wrong window)
Note over PH: press lifecycle broken ❌
Note over E,GW: After fix
E->>PH: pointerdown
PH->>GEW: getEventTargetWindow(element)
GEW-->>PH: iframe.contentWindow
PH->>IW: addEventListener("pointerup", ...)
E->>IW: pointerup (bubbles up to iframe window)
IW->>PH: onPointerUp fires
Note over PH: press lifecycle completes ✅
Reviews (1): Last reviewed commit: "Fix press gestures in portal windows" | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
windowpress(window, ...)andpress(document, ...)behavior while fixing elements rendered into another document/windowmotion-domand portal-mountedwhileTap/tap callbacks inframer-motionRoot Cause
press(...)inmotion-domattachedpointerupandpointercancellisteners to the globalwindow. When a press started on an element rendered into anotherdocument/window, the release lifecycle was tracked on the wrong browsing context, sowhileTap,onTapStart,onTap, andonTapCancelcould fail or immediately break.Fix
Resolve the window from the press target:
Windowtargets use themselvesDocumenttargets usedefaultViewownerDocument.defaultViewThat resolved window is then used for the pointer lifecycle listeners.
Testing
motion-domregression test for press lifecycle handling in both the current window and an owning iframe windowframer-motionregression test covering a portal-renderedmotion.buttonwithwhileTap,onTapStart,onTap, andonTapCancelNotes