Skip to content

fix(core): a layout motion's copy carries on the CSS animations and transitions running in it - #9534

Merged
cixzhang merged 2 commits into
meta:mainfrom
vjeux:uikit/f1-copy-carries-css-motion
Nov 4, 2026
Merged

cixzhang merged 2 commits into
meta:mainfrom
vjeux:uikit/f1-copy-carries-css-motion

Conversation

@vjeux

@vjeux vjeux commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

User impact

A layout motion's transient copy of old content (an in-place swap's, or the SideNav rail's and AppShell content's old state) showed what its element no longer did: a played entrance played again, a looping CSS animation restarted, and a running transition jumped to its end. On a phone, a SideNav toggle's fading press highlight lit again in the copy, under Reduce Motion too.

Problem and solution fit

  • Why it happens. The copy is a clone (inertCopy), and a clone starts each CSS animation again and runs no transition but a @starting-style one.
  • The fix. inertCopy saves the element's running CSS animations and transitions, and placeOver carries them on in the copy: a restarted CSS animation takes its element's state, a transition runs on as a script animation, and anything else started afresh (a played entrance, a @starting-style fade-in) is finished.

Expected behavior and authority

spec:AST-105 FR8 and FR9 hold old content as one transient copy. No current record says how a copy treats its running animations, so this is an implementation fix with no record change. Layer re-placement keeps its behavior (architecture:layer-runtime).

Smallest restoration

  • motion/carryAnimations.ts (new): the layer runtime's save and restore steps, moved from Layer/preserveAnimations.ts, plus a form for a copy.
  • motion/transientCopy.ts: inertCopy saves, placeOver carries, and visiblePartCopy hands the state to its holder.
  • The rail's Reduce Motion cases count the press feedback of the toggle's copy.

Evidence

  • On main: the copy case ("a copy carries on the CSS animations and transitions running in the old state, …") fails (its loop runs 400 ms behind), as does the rail case "under Reduce Motion a press held past its onset still only cross-fades, …" (the copy's press fade starts 16.6 ms late). The new case "a layer placed afresh does not play an ended @starting-style fade-in again, …" passes there, and failed 3 of 3 with the earlier fix (c23f803).
  • At this head (on main 217fc46): the new cases pass 10 of 10 in Chromium and WebKit, and the rail's Reduce Motion cases 35 of 35. Build, Storybook, type check, test:ui (19,741) and node (16,276) pass. Interaction passes 537 in Chromium and 475 in WebKit, none failing. CI=true lint and api:report --check fail only on main's own state (test(DateInput): the wheel contrast proof imports the hermetic Playwright test #9888's import; report rows for files this change leaves alone). Before the rebase, the a11y specs passed (223).

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

pnpm test:interaction --project=chromium -g "a copy carries on|placed afresh" packages/core/src/motion/__tests__/animatedLayout.interaction.browser.spec.ts packages/core/src/Layer/__tests__/preserveAnimations.interaction.browser.spec.ts
pnpm storybook:build
pnpm test:interaction --project=chromium -g "Reduce Motion" packages/core/src/SideNav/__tests__/SideNavRailMotion.interaction.browser.spec.ts

For WebKit, use the CI WebKit job's container command (internal/interaction-harness/scripts/webkit-container.mjs) with podman --cpus=4, CI=1, LP_NUM_THREADS=4 and 1 worker.

An earlier full Chromium run at this head failed two harness page-freeze self-tests (clock drift); the side-by-side runs passed them on both trees. The WebKit runs write the shader-cache marker as webkit-container.mjs does. The a11y group-matrix case needs the Storybook source stamp CI writes (git rev-parse HEAD > apps/storybook/dist/astryx-build-sha.txt); with it, it passes 2 of 2.

@vercel

vercel Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 4, 2026 12:25pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 2, 2026
@astracat-bot

astracat-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 4, 2026, 12:36 PM UTC

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · a53d1bc

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
LayerProvider 62.9 kB (+54 B) · 9.4 kB CSS (0) — ✓ · ✓ · ✗
SideNav 71.2 kB (+344 B) · 10.1 kB CSS (0) — ✓ · ✓ · ✓
AppShell 70.8 kB (+343 B) · 12.2 kB CSS (0) — — · — · —
113 more components
Component Size LoC Visual · A11y · RTL
SegmentedControl 81.8 kB (+89 B) · 6.7 kB CSS (0) — — · — · —
Popover 51.7 kB (+85 B) · 12.8 kB CSS (0) — — · — · —
lab/TransferList 74.8 kB (+85 B) · 1.7 kB CSS (0) — — · — · —
Carousel 49.3 kB (+83 B) · 9.5 kB CSS (0) — — · — · —
lab/CommentPin 46.9 kB (+83 B) · 1.2 kB CSS (0) — — · — · —
Table 83.4 kB (+81 B) · 16.1 kB CSS (0) — — · — · —
MoreMenu 72.9 kB (+80 B) · 15.6 kB CSS (0) — — · — · —
lab/ListInput 81.9 kB (+80 B) · 1.6 kB CSS (0) — — · — · —
lab/TourStep 57.6 kB (+80 B) · 590 B CSS (0) — — · — · —
richtext/RichTextEditorToolbar 224.7 kB (+79 B) · 454 B CSS (0) — — · — · —
lab/ChatReactionBar 66.0 kB (+78 B) · 1.1 kB CSS (0) — — · — · —
lab/Schedule 60.1 kB (+78 B) · 3.9 kB CSS (0) — — · — · —
DateRangeInput 70.9 kB (+77 B) · 11.2 kB CSS (0) — — · — · —
InfoTip 36.9 kB (+77 B) · 5.0 kB CSS (0) — — · — · —
ChatComposerInput 59.2 kB (+76 B) · 10.0 kB CSS (0) — — · — · —
Link 42.6 kB (+76 B) · 6.9 kB CSS (0) — — · — · —
PowerSearch 240.4 kB (+76 B) · 21.8 kB CSS (0) — — · — · —
Thumbnail 49.4 kB (+76 B) · 10.3 kB CSS (0) — — · — · —
Avatar 34.5 kB (+75 B) · 5.4 kB CSS (0) — — · — · —
DateInput 150.6 kB (+75 B) · 15.5 kB CSS (0) — — · — · —
DateTimeInput 172.8 kB (+75 B) · 17.2 kB CSS (0) — — · — · —
DropdownMenuSubMenu 56.8 kB (+75 B) · 8.9 kB CSS (0) — — · — · —
BaseTypeahead 55.1 kB (+74 B) · 9.6 kB CSS (0) — — · — · —
ChatComposerTokenElement 59.2 kB (+74 B) · 10.0 kB CSS (0) — — · — · —
BreadcrumbItem 67.6 kB (+73 B) · 10.8 kB CSS (0) — — · — · —
Markdown 144.8 kB (+73 B) · 18.4 kB CSS (0) — — · — · —
TopNavHeading 58.4 kB (+73 B) · 9.7 kB CSS (0) — — · — · —
lab/ChatEmojiPicker 65.5 kB (+73 B) · 773 B CSS (0) — — · — · —
lab/CommentComposer 104.4 kB (+73 B) · 1.9 kB CSS (0) — — · — · —
MobileNav 51.9 kB (+72 B) · 9.3 kB CSS (0) — — · — · —
SideNavItem 54.7 kB (+72 B) · 9.8 kB CSS (0) — ✓ · ✓ · ✓
Tokenizer 69.6 kB (+72 B) · 17.1 kB CSS (0) — — · — · —
Pagination 86.4 kB (+71 B) · 16.1 kB CSS (0) — — · — · —
Selector 77.5 kB (+71 B) · 15.7 kB CSS (0) — — · — · —
TableHeaderCell 74.8 kB (+71 B) · 15.6 kB CSS (0) — — · — · —
AvatarGroupOverflow 38.7 kB (+70 B) · 5.5 kB CSS (0) — — · — · —
ContextMenu 74.0 kB (+70 B) · 15.5 kB CSS (0) — — · — · —
DropdownMenu 72.6 kB (+70 B) · 15.6 kB CSS (0) — — · — · —
StatusDot 22.5 kB (+70 B) · 5.2 kB CSS (0) — — · — · —
IconButton 45.2 kB (+69 B) · 8.7 kB CSS (0) — — · — · —
SideNavCollapseButton 46.0 kB (+69 B) · 8.8 kB CSS (0) — ✓ · ✓ · ✓
TabList 35.5 kB (+69 B) · 6.4 kB CSS (0) — — · — · —
Stepper 46.7 kB (+68 B) · 8.9 kB CSS (0) — — · — · —
Button 45.1 kB (+67 B) · 8.7 kB CSS (0) — — · — · —
MultiSelector 72.7 kB (+67 B) · 15.3 kB CSS (0) — — · — · —
TableCell 75.2 kB (+67 B) · 15.9 kB CSS (0) — — · — · —
TopNavMenu 58.3 kB (+67 B) · 9.9 kB CSS (0) — — · — · —
AvatarGroup 37.2 kB (+66 B) · 5.5 kB CSS (0) — — · — · —
Toolbar 34.8 kB (+66 B) · 7.9 kB CSS (0) — — · — · —
Tooltip 20.3 kB (+66 B) · 3.9 kB CSS (0) — — · — · —
lab/DiffViewer 71.0 kB (+66 B) · 2.1 kB CSS (0) — — · — · —
ChatDictationButton 45.7 kB (+65 B) · 8.8 kB CSS (0) — — · — · —
Banner 47.1 kB (+64 B) · 9.2 kB CSS (0) — — · — · —
MobileNavToggle 45.5 kB (+64 B) · 8.7 kB CSS (0) — — · — · —
SideNavHeading 59.0 kB (+64 B) · 9.9 kB CSS (0) — ✓ · ✓ · ✓
richtext/RichTextView 258.5 kB (+64 B) · 2.3 kB CSS (0) — — · — · —
ChatComposer 61.3 kB (+63 B) · 10.6 kB CSS (0) — — · — · —
ChatLayoutScrollButton 45.7 kB (+63 B) · 8.9 kB CSS (0) — — · — · —
ChatSendButton 45.5 kB (+63 B) · 8.7 kB CSS (0) — — · — · —
HoverCard 19.3 kB (+63 B) · 3.9 kB CSS (0) — — · — · —
ToggleButton 46.0 kB (+63 B) · 8.8 kB CSS (0) — — · — · —
TopNav 53.4 kB (+63 B) · 9.6 kB CSS (0) — — · — · —
lab/TransferListSelector 82.4 kB (+63 B) · 1.9 kB CSS (0) — — · — · —
AlertDialog 83.4 kB (+62 B) · 13.1 kB CSS (0) — — · — · —
RadioList 40.8 kB (+62 B) · 6.4 kB CSS (0) — — · — · —
CheckboxInput 48.5 kB (+61 B) · 8.7 kB CSS (0) — — · — · —
DrawerHeader 48.1 kB (+61 B) · 11.6 kB CSS (0) — — · — · —
Field 39.3 kB (+61 B) · 6.3 kB CSS (0) — — · — · —
TextInput 52.9 kB (+61 B) · 9.9 kB CSS (0) — — · — · —
Toast 59.1 kB (+61 B) · 9.0 kB CSS (0) — — · — · —
lab/CommentThread 255.4 kB (+61 B) · 2.4 kB CSS (0) — — · — · —
DialogHeader 47.9 kB (+60 B) · 10.2 kB CSS (0) — — · — · —
FieldLabel 35.5 kB (+60 B) · 4.8 kB CSS (0) — — · — · —
Calendar 54.3 kB (+59 B) · 9.3 kB CSS (0) — — · — · —
ChatLayout 48.3 kB (+59 B) · 9.3 kB CSS (0) — — · — · —
CheckboxList 43.1 kB (+59 B) · 7.5 kB CSS (0) — — · — · —
ComplexSelector 55.7 kB (+59 B) · 10.4 kB CSS (0) — — · — · —
Lightbox 52.2 kB (+59 B) · 9.1 kB CSS (0) — — · — · —
TableSelectionToolbar 54.6 kB (+59 B) · 11.8 kB CSS (0) — — · — · —
TopNavMegaMenu 54.1 kB (+59 B) · 10.6 kB CSS (0) — — · — · —
charts/Chart 156.3 kB (+58 B) · 494 B CSS (0) — — · — · —
charts/ChartTooltip 133.1 kB (+58 B) · 423 B CSS (0) — — · — · —
Switch 87.1 kB (+58 B) · 9.5 kB CSS (0) — — · — · —
TimeInput 137.0 kB (+58 B) · 14.5 kB CSS (0) — — · — · —
NumberInput 55.1 kB (+57 B) · 10.1 kB CSS (0) — — · — · —
ListItem 52.5 kB (+56 B) · 10.0 kB CSS (0) — — · — · —
richtext/RichTextEditor 278.3 kB (+56 B) · 2.6 kB CSS (0) — — · — · —
CodeBlock 58.9 kB (+55 B) · 10.0 kB CSS (0) — — · — · —
FileInput 53.7 kB (+55 B) · 9.7 kB CSS (0) — — · — · —
TabMenu 55.6 kB (+55 B) · 9.8 kB CSS (0) — — · — · —
TextArea 46.7 kB (+55 B) · 8.8 kB CSS (0) — — · — · —
Typeahead 62.9 kB (+55 B) · 11.2 kB CSS (0) — — · — · —
CheckboxListItem 53.2 kB (+53 B) · 10.0 kB CSS (0) — — · — · —
RadioListItem 51.1 kB (+53 B) · 9.0 kB CSS (0) — — · — · —
lab/Comments 260.7 kB (+52 B) · 2.5 kB CSS (0) — — · — · —
InputGroup 41.5 kB (+51 B) · 7.3 kB CSS (0) — — · — · —
lab/EmojiPicker 70.4 kB (+47 B) · 722 B CSS (0) — — · — · —
Slider 88.7 kB (+42 B) · 8.3 kB CSS (0) — — · — · —
lab/SelectableCardGroup 50.3 kB (+42 B) · 162 B CSS (0) — — · — · —
Text 7.4 kB (+2 B) · 4.9 kB CSS (0) — — · — · —
CommandPaletteInput 26.9 kB (+1 B) · 7.4 kB CSS (0) — — · — · —
Heading 7.9 kB (+1 B) · 4.9 kB CSS (0) — — · — · —
ProgressBar 10.8 kB (+1 B) · 6.2 kB CSS (0) — — · — · —
Spinner 18.5 kB (+1 B) · 5.7 kB CSS (0) — — · — · —
ChatMessageList 22.8 kB (0) · 6.9 kB CSS (0) — — · — · —
CommandPalette 51.2 kB (0) · 12.3 kB CSS (0) — — · — · —
SideNavSection 6.6 kB (0) · 3.7 kB CSS (0) — ✓ · ✓ · ✓
Timer 9.5 kB (0) · 5.9 kB CSS (0) — — · — · —
ChatToolCalls 25.9 kB (−1 B) · 8.2 kB CSS (0) — — · — · —
charts/ChartLegend 34.4 kB (−2 B) · 224 B CSS (0) — — · — · —
Timestamp 21.3 kB (−2 B) · 8.9 kB CSS (0) — — · — · —
layer — — — · ✓ · —
Layer — — ✓ · ✓ · —

Package size: @astryxdesign/core 6.38 MB packed (+5.1 kB); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 8 rows, theme-butter 1 row, theme-chocolate 1 row, theme-gothic 1 row, theme-matcha 1 row, theme-neutral 1 row, theme-stone 1 row, theme-y2k 1 row; run pnpm api:report.

Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the copy now carries on loops, transitions and forward-filled entrances, but an entrance that ended without a forward fill still replays in it, and every useEntryAnimation preset is such an entrance (a FieldStatus message slides in again in AppShell's content copy during a side nav collapse).

  • Finish each restarted CSS animation in the copy that has no running counterpart, as Layer/preserveAnimations.ts already does, drop the early return when nothing was noted, and add a module case with a backwards-filled entrance.
  • Share the save-and-restore logic with Layer/preserveAnimations.ts instead of keeping a second version of it in transientCopy.ts; the two have already drifted apart.
  • Until that case is fixed, the changeset's "an entrance played again" does not hold, so fix it or narrow the wording.

[Automated review]

Comment on lines +296 to +299
if (index !== -1) {
carryOn(restarted.splice(index, 1)[0], state);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A finished CSS animation with animation-fill-mode: backwards or none is not returned by getAnimations() (it is neither current nor in effect). Its restart in the copy therefore has no match here and plays again from 0 ms, and every useEntryAnimation preset is backwards. Layer/preserveAnimations.ts finishes a recreated animation with no predecessor; doing the same here fixes it:

for (const animation of restarted) {
  if (Number.isFinite(Number(animation.effect?.getComputedTiming().endTime))) {
    animation.finish();
  }
}

The running.length === 0 early return above also needs to go, so that a copy whose only CSS motion is a finished entrance still reaches this loop.

* noted against the copy's element at the same place. Script animations are
* left to their owners: the module drives a copy's motion itself.
*/
function readRunningCss(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic repeats what Layer/preserveAnimations.ts already does: it saves the state, matches recreated CSS animations by element, pseudo-element and name, restores rate, play state and time, and resumes transitions as script animations. The two have already drifted: that one also finishes a recreated animation with no predecessor and restores more members. A save step and a restore step that takes a source-to-copy node map would let inertCopy and placeOver call it instead of keeping a second version.

Comment thread .changeset/copy-carries-css-motion.md Outdated
'@astryxdesign/core': patch
---

[fix] The transient copy a layout motion holds of old content (an in-place swap's old content, the SideNav rail's and AppShell content's old state during a collapse or expand) carries on the CSS animations and transitions running in it from where they were. It no longer starts each CSS animation again (a press highlight lit again, an entrance played again) or shows a transition's end at once.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"It no longer starts each CSS animation again (… an entrance played again)" holds only for an entrance that keeps a forward fill. A backwards- or none-filled entrance still replays, and every useEntryAnimation preset is backwards. Fix that case, or narrow the wording, for example to "a running or paused CSS animation, or an entrance that holds its end".

Comment on lines +18 to +21
* host draws it at the old size. The CSS animations and transitions running
* in the element carry on in the copy from where they were: a clone starts
* each CSS animation again from its start (an entrance that had played plays
* again) and runs no transition (it shows the end value at once). Laid in a host outside the element's own

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this sentence has 46 words and several topics, and it repeats the inertCopy and placeOver JSDoc. The header is now 30 lines. Consider dropping it, or: "A clone restarts each CSS animation and runs no transition. The copy carries on its element's ones from where they were."

@vjeux
vjeux force-pushed the uikit/f1-copy-carries-css-motion branch from d0fcd6e to c23f803 Compare November 2, 2026 13:58
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 2, 2026
@vjeux

vjeux commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in c23f803:

  1. An entrance that had played and been dropped (backwards-filled or unfilled) no longer replays: the copy finishes each CSS animation it started that has no saved counterpart, through the same code as Layer/preserveAnimations.ts, and there is no early return. The module case now has a backwards-filled and an unfilled entrance; both replayed at the previous head (0px 20px against none).
  2. The save-and-restore logic is shared. It moves, as it was, from Layer/preserveAnimations.ts into motion/carryAnimations.ts; preserveAnimations calls it, and inertCopy and placeOver call its copy form, saveAnimations and carryAnimations, which take a map from each element to its copy. The copy's animations take no id or event handler, since the element's own keep running. The one change on the layer's path: an unmatched animation that never ends is left running, where finish() would throw. The Tooltip re-placement cases, that path's own proof, pass unchanged.
  3. The changeset now says "an entrance that had played playing again, whatever its fill".
  4. The header sentence is now two short ones.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the copy now carries on loops, transitions and played entrances, and the earlier findings are fixed. But the shared restore step also changes the layer's re-placement. restoreAnimations now keeps only CSSAnimations as recreated (carryAnimations.ts:313-315), so a transition that the display reset starts is no longer finished. An ended @starting-style fade-in in a context layer's content, such as a streamed Markdown segment, plays again from opacity 0 when the layer is placed afresh. Select recreated animations as before (after.filter(animation => !survivors.has(animation))), keep finishIfItEnds, and add a re-placement case with an @starting-style transition. That change also stops the copy replaying such entrances.

[Automated review]

}
}
const recreated = after.filter(
animation => isCssAnimation(animation) && !survivors.has(animation),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This filter is new on the layer path. Before, preserveAnimations took every animation the reset created and finished the unmatched ones. A display reset starts an @starting-style transition again, so an ended fade-in in a context layer's content (each streamed Markdown segment, for example) now plays again from opacity 0 when placeAfresh runs. On the base it was finished at once. Dropping isCssAnimation(animation) && restores that, and it also stops the copy replaying such entrances:

const recreated = after.filter(animation => !survivors.has(animation));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5f3813a. restoreAnimations again counts every CSS animation and transition the reset or the clone started as recreated, and keeps finishIfItEnds, so an ended @starting-style fade-in is finished on re-placement and in the copy. It is narrower than the old filter in one way: script animations stay out, since a display reset leaves them running. New case: Layer/__tests__/preserveAnimations.interaction.browser.spec.ts; the copy case also gains a @starting-style element. Both fail at c23f803's code.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet. The copy that a layout swap or the SideNav rail's collapse holds now carries on its element's loops, transitions, entrances and press fade, each new case fails on main and passes here, and the earlier findings are fixed.

  • Next step: mark the pull request ready for review, and a maintainer adds the ci:run label (then pushes, or closes and reopens) so CI runs.
  • Miss: (non-blocking) placeOver measures the copy before it carries the motion (transientCopy.ts:279 runs before :305), so a copied element whose own root ran a translate entrance lands offset by that entrance (24 px in a fixture); no Core surface reaches this today, and carrying before the measurement fixes it.

[Automated review]

Comment on lines +305 to +313
const carried = carriedMotion.get(element);
if (carried != null) {
carriedMotion.delete(element);
carryAnimations(
carried.saved,
element,
node => carried.copyOf.get(node) ?? null,
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this carry runs after origin and the scale are read (line 279). If the copied element's own root runs a CSS translate, transform or scale animation or transition (a played entrance, a @starting-style slide), the box is read with the clone's restarted value, and this carry then finishes or rewinds it. In a fixture with a root entrance from translate: 0 24px, the copy lands 24 px above the element from its first frame. Core's adopters do not reach it today: the rail element has no CSS motion, and AppShell copies into a fresh holder. Moving this block above line 279 measures the copy with its carried motion.

Comment on lines +14 to +21
* animations again from the stylesheet, at their start. It starts no
* transition but one from `@starting-style`, and script-created animations
* are untouched. `preserveAnimations` reads every animation's state first.
* Afterwards it gives each recreated CSS animation that state, and resumes
* each cancelled transition with a script animation at the same point. Any
* other animation the return started is finished, unless it never ends
* (motion/carryAnimations.ts). The browser fires
* `animationcancel`/`transitioncancel` for the old ones and `animationstart`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking (comment style): the header is now 21 lines, and this prose repeats the restoreAnimations JSDoc. Keep only the platform quirk, for example:

 * Taking an element out of rendering cancels its CSS animations and
 * transitions. On return, the browser starts the animations again from their
 * start. It starts no transition except one from `@starting-style`.

@vjeux
vjeux marked this pull request as ready for review November 4, 2026 04:13
@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 4, 2026
@cixzhang
cixzhang marked this pull request as draft November 4, 2026 04:41
@cixzhang
cixzhang marked this pull request as ready for review November 4, 2026 04:41
@vjeux
vjeux marked this pull request as draft November 4, 2026 06:17
…ransitions running in it

The copy an in-place swap or a two-state edge reveal holds of the old
content is a clone, and a clone starts every CSS animation again from its
start and runs no transition. So the copy showed something its element no
longer did: an entrance that had played played again, a looping animation
jumped back, and a transition in progress jumped to its end. On a phone, a
SideNav toggle pressed long enough that its press highlight was already
fading when the rail collapsed lit its highlight again in the old state's
copy.

inertCopy now saves the state of the CSS animations and transitions
running in the element, and placeOver carries them on in the copy once it is
laid out. The carry-over the layer runtime uses across a display reset moves
into motion/carryAnimations.ts, which Layer/preserveAnimations.ts now calls,
and gains a form that takes a map from each element to its copy: each CSS
animation the clone started again takes its element's state, each transition
runs on as a script animation, and each one the clone started that its
element no longer ran is finished, so an entrance that had played, whatever
its fill, does not play again. A `@starting-style` fade-in that the clone
or a display reset starts again is finished too, as the layer runtime
already did for a display reset. The copy's animations take no id or event
handler, since the element's own keep running. Script animations are left to
the module, which drives a copy's motion itself. Finishing an unmatched
animation now leaves one that never ends running, where finish() would
throw.

The SideNav rail's Reduce Motion cases count press feedback on any element
the press model marks, the toggle's copy included, as press feedback, as they
already did for the toggle itself.
@vjeux
vjeux force-pushed the uikit/f1-copy-carries-css-motion branch from 5f3813a to b2cceff Compare November 4, 2026 06:39

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet. The copy that a layout swap or the SideNav rail's collapse holds now carries on its element's loops, transitions, entrances and press fade, and each new case fails on main and passes here.

  • Next step: mark the pull request ready for review; it already carries ci:run, so CI then runs.
  • Non-blocking: placeOver still measures the copy before it carries the motion (transientCopy.ts:279 runs before :305), so a copied element whose own root ran a translate entrance lands offset by that entrance (24 px in a fixture); no Core surface reaches this today, and carrying before the measurement fixes it.

[Automated review]

@vjeux
vjeux marked this pull request as ready for review November 4, 2026 07:02
@cixzhang
cixzhang marked this pull request as draft November 4, 2026 07:22
@cixzhang
cixzhang marked this pull request as ready for review November 4, 2026 07:22
@cixzhang
cixzhang marked this pull request as draft November 4, 2026 12:18
@cixzhang
cixzhang marked this pull request as ready for review November 4, 2026 12:18

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI is still running on this head. The copy that a layout swap or the SideNav rail's collapse holds now carries on its element's loops, transitions, entrances and press fade, and each new case fails on main and passes here, also after the merge of main.

  • Non-blocking: placeOver still measures the copy before it carries the motion (transientCopy.ts:279 runs before :305), so a copied element whose own root ran a translate entrance lands offset by that entrance (24 px in a fixture); no Core surface reaches this today, and carrying before the measurement fixes it.

[Automated review]

@cixzhang
cixzhang merged commit 8ddcfe1 into meta:main Nov 4, 2026
75 of 114 checks passed
@vjeux
vjeux deleted the uikit/f1-copy-carries-css-motion branch November 4, 2026 13:10

This branch was successfully deployed

1 active deployment
Preview — a53d1bcc Deployed Nov 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants