Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
Generated by PR Enrichment workflow | View current CI run |
There was a problem hiding this comment.
Changes are needed, and approval also waits on an engineering owner's decision about the behavior itself.
useAnimatornow drops its values when its element moves to another document: after the move and a render,get()reportsx0 andopacity1 while the element still shows its offset, and the nextset()jumps it back (useAttachment.ts:82-86releasing throughanimator/createAnimator.ts:285-290), which contradictsspec:AST-107FR3, so keep the animator out of the document re-check and add auseAnimatortest for the move.- The title and changeset say gestures, press tracking, the pager and the animator attach again when the element moves, but the re-check runs only at the component's next render, Switch and Slider attach outside
useAttachmentand stay on the old document, and re-attaching the animator moves nothing to the new document, so reword both to match, for example: "When code outside React moves a mounted element into another document, such as a Picture-in-Picture window, its gesture recognizers, press tracking and pager attach in that document at the component's next render, instead of staying bound to the old one."
No current record makes a node's move into another document an attachment lifecycle event: architecture:react-component-runtime INV6 names attachment, null detachment and replacement only. An engineering owner needs to decide that behavior and name or add the clause that governs it, and records the decision by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner. The two fixes above are needed either way.
[Automated review]
| nodes.every( | ||
| (node, index) => | ||
| node === current.nodes[index] && | ||
| node.ownerDocument === current.documents[index], |
There was a problem hiding this comment.
This re-check also reaches useAnimator, whose release (attachElement(null) in useAnimator.ts) resets every channel to rest (animator/createAnimator.ts:285-290). After a move and a render, get() reports x 0 while the element still shows its offset, and the next set() jumps it, which contradicts spec:AST-107 FR3. Re-attaching moves nothing of the animator's to the new document (it reads ownerDocument.defaultView per call and keeps the page's frame clock), so it can stay out of this check, for example through an opt-in that only the gesture-host callers pass. A useAnimator test for the move would cover it.
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] An element's gesture recognizers, press tracking, pager and animator attach again when the element moves to another document, such as a Picture-in-Picture window, instead of staying bound to the old one. |
There was a problem hiding this comment.
This promises more than the change does: the re-check runs only at the component's next render, Switch and Slider attach outside useAttachment and stay on the old document, and re-attaching the animator moves nothing to the new document. Suggested: "[fix] When code outside React moves a mounted element into another document, such as a Picture-in-Picture window, its gesture recognizers, press tracking and pager attach in that document at the component's next render, instead of staying bound to the old one."
| * made once every node is there, and released when a node, a node's document | ||
| * or `key` changes and at unmount. |
There was a problem hiding this comment.
Non-blocking (comment style): this sentence is passive. Suggested: "It attaches once every node is there. It releases the attachment at unmount and when a node, a node's document or key changes."
1a08cd3 to
bac57ef
Compare
|
/approve-spec bac57ef |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. It is a draft from a fork, so CI runs once it is marked ready and a maintainer adds the ci:run label.
The opt-in followsDocument option has no caller yet, every current caller keeps its attachment (and useAnimator its values) across a document move, and the new tests fail without the change. Whether a menu press should follow its document is for the first caller that opts in to settle.
[Automated review]
| * With `followsDocument`, a node that moves to another document is released | ||
| * and attached again. |
There was a problem hiding this comment.
Non-blocking (comment style): this sentence is passive and does not say when the re-attach happens. Suggested: "With followsDocument, it also releases a node that moved to another document and attaches it again at the next commit."
… for a caller that asks An attachment that listens on its node's document, as the menu press does, must attach again when the node moves into another document, such as a Picture-in-Picture window. useAttachment gains an internal followsDocument option for that. No current caller passes it, so the gesture hooks, the pager and useAnimator keep their behavior: a document move leaves their attachment as it is, and useAnimator keeps its values.
bac57ef to
c6a1cb5
Compare
There was a problem hiding this comment.
This pull request is reviewed as part of its stack; see the review on #8458.
|
Closing: its option's only caller was #9504, which is closed. |
Maintainer impact
The menu press's ref form attaches listeners on its menu's document, so it must attach again when its menu moves into another document, such as a Picture-in-Picture window.
useAttachmentis the shared attach-and-release path the gesture hooks, the pager anduseAnimatoruse, and the menu press moves onto it in #9504. It had no way to follow a node into another document.Intended invariant
architecture:react-component-runtimeINV5 and INV6 stay as they are for every current caller. A replaced node is released before the new one attaches, a commit that changes nothing does nothing, and a node that moves to another document keeps its attachment unless its caller asks otherwise.useAnimatorkeeps its values across such a move (spec:AST-107FR3).Change
useAttachmenttakes an internal option,{followsDocument: true}. With it,useAttachedNodesrecords each node's document and, when a node moves to another document, releases the attachment and attaches it again.useAttachmentPairand every current caller pass no option, so their behavior is unchanged. No behavior change: no caller opts in until #9504.Evidence
useAttachmentas on main (NOT-FOR-LANDING arm eb8815f), the opt-in case fails.useAttachmentanduseAttachmentPairkeep their attachment across a document move, anduseAnimatorkeeps its values. With an earlier version that followed the document for every caller (arm ad7525b), those three cases fail.Scope
Stack: #9910 → #9504 → #8458.
#9504 edits this PR's changeset, so the two merge in one release.
Testing
At c6a1cb5, this pull request is rebased onto main 5083ead with no change: the same patch as bac57ef, so #9504 stacks on exactly this head. The core type check and this pull request's tests (16 of 16) pass there; the gates below ran at bac57ef.
Local gates at bac57ef on main a343c79: the core type check,
pnpm lint, strict lint, Prettier, the knowledge and changeset checks andreview:pre; the gesture, press tracker, pager, animator, motion and hooks units (2,555 of 2,556; the one failure, PowerSearch's bottom-sheet adopter case, timed out finding a lazily loaded search box on a heavily loaded box and passes three runs of three here and on main). The coreuisuite: 18,124 passed. The RadioListItem and Switch source-build tests fail the same way on main in this checkout because a Babel preset does not resolve. Markdown's FR23 overhead case and PowerSearch's SSR case timed out on the loaded box; both pass two runs of two here and on main. On a fresh Storybook build, the gesture, pager and animator interaction specs in Chromium: 119 passed, 6 skipped. NOT-FOR-LANDING arms: eb8815f, main'suseAttachmentunder this head's tests, fails the opt-in case; ad7525b, a version that followed the document for every caller, fails the three unchanged-caller cases,useAnimator's included.