Skip to content

fix(Layer): a closed layer's trigger is no CSS anchor - #9963

Merged
cixzhang merged 2 commits into
meta:mainfrom
vjeux:uikit/c08-layer-anchor
Nov 4, 2026
Merged

cixzhang merged 2 commits into
meta:mainfrom
vjeux:uikit/c08-layer-anchor

Conversation

@vjeux

@vjeux vjeux commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

User impact

In WebKit's Linux ports (Playwright's WebKit), a transform animation on an element containing a closed Tooltip, Popover or menu trigger stops while the main thread is busy. Every useLayer trigger carried its anchor-name from mount, and that engine animates an element holding an anchor on the main thread. Mobile Safari (iOS 26.2 Simulator) and Chromium keep it running.

Problem and solution fit

Only a shown layer is placed against its trigger, yet every trigger was named at mount, failing CI's WebKit busy-thread proofs. Naming it only while the layer is shown or animating out removes closed anchors.

Expected behavior and authority

architecture:layer-runtime INV18, in the owner's words: "A trigger carries its CSS anchor name only while its layer is shown; a closed trigger is not an anchor, so a surface that moves around it keeps its transform animation off the main thread." This change adds: "A layer that animates out counts as shown until its animations end."

Smallest restoration

show() names the trigger before showPopover. A refused show unnames it, as do hide() and the browser's close once the layer's finite animations end. A show or a re-attached trigger during that exit keeps the name; a trigger attached while closed gets none. Open #5398 names every attach there; its rebase must keep this rule. An exit copy outside the layer (spec:AST-090) must place itself from captured geometry.

Evidence

The Tooltip story's root moves around the closed trigger through a 500 ms main-thread block.

Before (main) After
WebKit, Linux Before, WebKit Linux: frozen during the block After, WebKit Linux: moving
iOS 26.2 Simulator Before, iOS Simulator: moving After, iOS Simulator: moving
  • Reproduction before the change: WebKit Linux moved on 1/34, 0/33, 0/34 block frames; a control moved.
  • Result after the change: every frame the control moves, in WebKit and Chromium.
  • Representative unchanged path: a shown tooltip sits above its trigger and follows a 120 px move; iOS moves either way.
  • Close fade: TopNavMegaMenu's panel stays at x 16; unnaming at close moved it to x 0.
  • Regression test: TooltipClosedTriggerAnchor.interaction.browser.spec.ts and nine useLayer.test.tsx cases.

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.

Writing rubric results

architecture:layer-runtime (INV18, its row) and component:Popover (trigger binding, side effects): R1 narration: none. R2 research: none. R3 evidence: the INV18 row names its tests and what each proves. R4 rejected alternatives: none. R5 change references: none. R6 open questions: none.

Testing

  • Red-first, TooltipClosedTriggerAnchor.interaction.browser.spec.ts in the Linux WebKit container (CI flags) against a Storybook built from main's useLayer.tsx: the moving-surface case fails 3/3 (1/34, 0/33, 0/34 frames moved); the positive control fails its closing check (the closed trigger keeps --astryx-layer-…). With this change both cases pass 4/4 runs (33/33, 34/34, 34/34, 33/33 frames moved, longest stall ≤ 17.2 ms against the control's). Chromium: both pass 2/2 (27/27); on main the moving case already passes there and the closing check fails.
  • useLayer.test.tsx: nine new cases (closed trigger has no name; hide and the browser's close remove it; two layers on one trigger keep their own names; a replaced trigger; the name stays through a close fade and for a show during it; a trigger attached again during the fade keeps it; an endless or a paused animation does not hold it; a show the browser refuses during the fade keeps it). The first four fail on main's useLayer.tsx; all pass here.
  • TopNavMegaMenu close fade (Chromium, --repeat-each=3): the panel stays within 2 px of its open x and 8 px of its open y through every painted fade frame, then the <nav> loses the name. A build that unnames at close fails it (x 16 → 0); main fails its last check (the <nav> keeps the name). WebKit skips it: the panel has display: none on the first frame after it closes, so no fade paints.
  • Existing tests that read a closed trigger's anchor name now open the layer first or expect none: Popover.test.tsx and DropdownMenu.test.tsx open the layer before the re-render they watch, so a trigger ref that re-attaches still fails them; ContextMenu.test.tsx, SideNav.test.tsx, useTableRowStatus.test.tsx.
  • Core units (vitest --project ui packages/core): 18,374 of 18,378 pass. The other 4, in two *.source-build.test.mjs files, fail identically on main in this checkout (its install lacks a Babel preset).
  • Browser specs under Layer, Tooltip, Popover, HoverCard, ContextMenu, DropdownMenu, TopNav, SideNav and Selector: a11y Chromium 414/414, a11y WebKit 27/27, interaction Chromium 23/23, interaction WebKit 8 pass (15 skip by design).
  • Core typecheck 0 errors; strict ESLint (CI=true) 0 errors; Prettier; pnpm check:knowledge.
  • iOS 26.2 Simulator (iPhone 17 Pro, Mobile Safari): the same story and block on each Storybook, order-balanced, 3 main and 2 fixed takes, a marker tracked frame by frame (it and the rig's beacons are cropped out of the clips); every frame of each clip watched.

@vercel

vercel Bot commented Nov 4, 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 7:46pm UTC

Request Review

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

astracat-bot Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

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

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · ea25020

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Avatar 35.0 kB (+220 B) · 5.4 kB CSS (0) — — · — · —
HoverCard · Storybook 19.5 kB (+208 B) · 3.9 kB CSS (0) 730 (0) — · — · —
Tokenizer 70.3 kB (+206 B) · 17.1 kB CSS (0) — — · — · —
122 more components
Component Size LoC Visual · A11y · RTL
InfoTip 37.8 kB (+203 B) · 5.0 kB CSS (0) — — · — · —
Toast 59.9 kB (+203 B) · 9.0 kB CSS (0) — — · — · —
MoreMenu 74.6 kB (+202 B) · 16.0 kB CSS (0) — — · — · —
Toolbar 35.0 kB (+202 B) · 7.9 kB CSS (0) — — · — · —
AvatarGroup 37.7 kB (+200 B) · 5.5 kB CSS (0) — — · — · —
richtext/RichTextView 259.0 kB (+200 B) · 2.3 kB CSS (0) — — · — · —
AvatarGroupOverflow 39.1 kB (+199 B) · 5.5 kB CSS (0) — — · — · —
richtext/RichTextEditor 278.6 kB (+198 B) · 2.6 kB CSS (0) — — · — · —
AppShell 73.5 kB (+196 B) · 12.2 kB CSS (0) — — · — · —
DropdownMenu 74.4 kB (+196 B) · 16.0 kB CSS (0) — — · — · —
DropdownMenuSubMenu 58.2 kB (+196 B) · 9.3 kB CSS (0) — — · — · —
TabList 35.7 kB (+195 B) · 6.4 kB CSS (0) — — · — · —
lab/CommentComposer 105.1 kB (+194 B) · 1.9 kB CSS (0) — — · — · —
StatusDot 23.0 kB (+193 B) · 5.2 kB CSS (0) — — · — · —
ChatComposerInput 59.7 kB (+192 B) · 10.0 kB CSS (0) — — · — · —
ChatComposerTokenElement 59.7 kB (+192 B) · 10.0 kB CSS (0) — — · — · —
FieldLabel 38.2 kB (+191 B) · 5.4 kB CSS (0) — — · — · —
FileInput 54.1 kB (+191 B) · 9.7 kB CSS (0) — — · — · —
lab/Schedule 60.9 kB (+191 B) · 3.9 kB CSS (0) — — · — · —
LayerProvider 63.6 kB (+190 B) · 9.4 kB CSS (0) — — · — · —
ComplexSelector 56.0 kB (+188 B) · 10.5 kB CSS (0) — — · — · —
TextInput 53.2 kB (+188 B) · 9.9 kB CSS (0) — — · — · —
Tooltip · Storybook 20.8 kB (+188 B) · 3.9 kB CSS (0) 817 (0) — · — · —
Typeahead 63.5 kB (+188 B) · 11.2 kB CSS (0) — — · — · —
RadioList 43.6 kB (+187 B) · 6.9 kB CSS (0) — — · — · —
SideNav 73.8 kB (+186 B) · 10.1 kB CSS (0) — — · — · —
TimeInput 138.4 kB (+186 B) · 14.5 kB CSS (0) — — · — · —
lab/EmojiPicker 71.0 kB (+186 B) · 722 B CSS (0) — — · — · —
BaseTypeahead 55.6 kB (+185 B) · 9.7 kB CSS (0) — — · — · —
ChatComposer 61.8 kB (+184 B) · 10.6 kB CSS (0) — — · — · —
InputGroup 43.2 kB (+184 B) · 7.3 kB CSS (0) — — · — · —
SideNavCollapseButton 46.3 kB (+183 B) · 8.8 kB CSS (0) — — · — · —
CheckboxList 44.8 kB (+182 B) · 7.5 kB CSS (0) — — · — · —
AlertDialog 87.0 kB (+181 B) · 13.1 kB CSS (0) — — · — · —
CodeBlock 59.4 kB (+181 B) · 10.0 kB CSS (0) — — · — · —
TableSelectionToolbar 55.1 kB (+181 B) · 11.8 kB CSS (0) — — · — · —
ToggleButton 46.4 kB (+181 B) · 8.8 kB CSS (0) — — · — · —
Field 42.1 kB (+180 B) · 6.9 kB CSS (0) — — · — · —
MobileNav 54.6 kB (+180 B) · 9.3 kB CSS (0) — — · — · —
Banner 47.5 kB (+179 B) · 9.2 kB CSS (0) — — · — · —
CheckboxListItem 54.4 kB (+179 B) · 10.4 kB CSS (0) — — · — · —
DialogHeader 48.3 kB (+179 B) · 10.2 kB CSS (0) — — · — · —
ListItem 53.7 kB (+179 B) · 10.4 kB CSS (0) — — · — · —
SegmentedControl 83.1 kB (+179 B) · 6.7 kB CSS (0) — — · — · —
DrawerHeader 48.5 kB (+178 B) · 11.6 kB CSS (0) — — · — · —
Stepper 47.1 kB (+178 B) · 8.9 kB CSS (0) — — · — · —
ChatLayoutScrollButton 46.0 kB (+177 B) · 8.9 kB CSS (0) — — · — · —
RadioListItem 52.2 kB (+177 B) · 9.4 kB CSS (0) — — · — · —
lab/DiffViewer 71.6 kB (+177 B) · 2.1 kB CSS (0) — — · — · —
TabMenu 56.7 kB (+176 B) · 9.9 kB CSS (0) — — · — · —
ChatDictationButton 46.1 kB (+175 B) · 8.8 kB CSS (0) — — · — · —
Switch 88.9 kB (+175 B) · 9.5 kB CSS (0) — — · — · —
lab/ChatEmojiPicker 66.1 kB (+175 B) · 773 B CSS (0) — — · — · —
CheckboxInput 48.9 kB (+174 B) · 8.7 kB CSS (0) — — · — · —
Calendar 54.7 kB (+173 B) · 9.3 kB CSS (0) — — · — · —
ChatLayout 48.7 kB (+173 B) · 9.3 kB CSS (0) — — · — · —
lab/Comments 265.5 kB (+173 B) · 2.5 kB CSS (0) — — · — · —
MobileNavToggle 45.8 kB (+171 B) · 8.7 kB CSS (0) — — · — · —
TextArea 48.4 kB (+171 B) · 8.8 kB CSS (0) — — · — · —
Carousel 49.9 kB (+170 B) · 9.5 kB CSS (0) — — · — · —
TopNav 56.1 kB (+170 B) · 9.6 kB CSS (0) — — · — · —
ChatSendButton 45.9 kB (+169 B) · 8.7 kB CSS (0) — — · — · —
IconButton 45.6 kB (+169 B) · 8.7 kB CSS (0) — — · — · —
NumberInput 55.3 kB (+169 B) · 10.2 kB CSS (0) — — · — · —
lab/ChatReactionBar 66.7 kB (+169 B) · 1.1 kB CSS (0) — — · — · —
BreadcrumbItem 69.6 kB (+168 B) · 11.3 kB CSS (0) — — · — · —
Button 45.5 kB (+168 B) · 8.7 kB CSS (0) — — · — · —
Table 85.0 kB (+167 B) · 16.6 kB CSS (0) — — · — · —
Thumbnail 49.8 kB (+167 B) · 10.3 kB CSS (0) — — · — · —
Markdown 146.4 kB (+166 B) · 18.8 kB CSS (0) — — · — · —
TopNavHeading 59.4 kB (+166 B) · 9.8 kB CSS (0) — — · — · —
Lightbox 52.8 kB (+165 B) · 9.1 kB CSS (0) — — · — · —
Link 43.0 kB (+164 B) · 6.9 kB CSS (0) — — · — · —
SideNavItem 55.1 kB (+164 B) · 9.8 kB CSS (0) — — · — · —
TopNavMenu 59.4 kB (+164 B) · 9.9 kB CSS (0) — — · — · —
lab/TransferList 76.0 kB (+164 B) · 1.7 kB CSS (0) — — · — · —
SideNavHeading 60.0 kB (+163 B) · 10.0 kB CSS (0) — — · — · —
lab/CommentThread 260.3 kB (+163 B) · 2.4 kB CSS (0) — — · — · —
lab/ListInput 82.2 kB (+163 B) · 1.6 kB CSS (0) — — · — · —
PowerSearch 245.2 kB (+162 B) · 22.2 kB CSS (0) — — · — · —
TableCell 76.9 kB (+162 B) · 16.3 kB CSS (0) — — · — · —
TableHeaderCell 76.4 kB (+162 B) · 16.1 kB CSS (0) — — · — · —
lab/SelectableCardGroup 50.6 kB (+162 B) · 162 B CSS (0) — — · — · —
ContextMenu · Storybook 75.7 kB (+161 B) · 15.9 kB CSS (0) 693 (0) — · — · —
DateRangeInput 71.5 kB (+161 B) · 11.2 kB CSS (0) — — · — · —
Pagination 88.2 kB (+160 B) · 16.5 kB CSS (0) — — · — · —
lab/CommentPin 47.3 kB (+160 B) · 1.2 kB CSS (0) — — · — · —
lab/TransferListSelector 83.7 kB (+160 B) · 1.9 kB CSS (0) — — · — · —
DateInput 152.2 kB (+159 B) · 15.5 kB CSS (0) — — · — · —
DateTimeInput 174.3 kB (+159 B) · 17.2 kB CSS (0) — — · — · —
lab/TourStep 58.2 kB (+159 B) · 590 B CSS (0) — — · — · —
Slider 91.2 kB (+158 B) · 8.3 kB CSS (0) — — · — · —
MultiSelector 73.3 kB (+156 B) · 15.3 kB CSS (0) — — · — · —
TopNavMegaMenu 54.6 kB (+156 B) · 10.6 kB CSS (0) — — · — · —
charts/Chart 160.5 kB (+153 B) · 494 B CSS (0) — — · — · —
Selector 79.4 kB (+153 B) · 16.2 kB CSS (0) — — · — · —
Popover · Storybook 52.3 kB (+152 B) · 12.8 kB CSS (0) 1,038 (0) — · — · —
charts/ChartTooltip 137.2 kB (+150 B) · 423 B CSS (0) — — · — · —
richtext/RichTextEditorToolbar 229.0 kB (+139 B) · 454 B CSS (0) — — · — · —
Heading 7.9 kB (+1 B) · 4.9 kB CSS (0) — — · — · —
Text 7.4 kB (+1 B) · 4.9 kB CSS (0) — — · — · —
charts/ChartLegend 34.4 kB (0) · 224 B CSS (0) — — · — · —
ChatMessageList 22.8 kB (0) · 6.9 kB CSS (0) — — · — · —
ChatToolCalls 25.9 kB (0) · 8.2 kB CSS (0) — — · — · —
CommandPaletteInput 26.9 kB (0) · 7.4 kB CSS (0) — — · — · —
ContextMenuItem 21.0 kB (0) · 6.0 kB CSS (0) — — · — · —
DropdownMenuCheckboxItem 19.3 kB (0) · 6.4 kB CSS (0) — — · — · —
DropdownMenuDivider 5.2 kB (0) · 548 B CSS (0) — — · — · —
DropdownMenuGroup 6.2 kB (0) · 3.4 kB CSS (0) — — · — · —
DropdownMenuItem 18.5 kB (0) · 6.0 kB CSS (0) — — · — · —
DropdownMenuRadioGroup 6.1 kB (0) · 3.4 kB CSS (0) — — · — · —
DropdownMenuRadioItem 19.3 kB (0) · 6.4 kB CSS (0) — — · — · —
ProgressBar 10.8 kB (0) · 6.2 kB CSS (0) — — · — · —
SideNavSection 6.6 kB (0) · 3.8 kB CSS (0) — — · — · —
Spinner 18.5 kB (0) · 5.7 kB CSS (0) — — · — · —
TableBody 3.4 kB (0) · 3.3 kB CSS (0) — — · — · —
TableFooter 3.4 kB (0) · 3.3 kB CSS (0) — — · — · —
TableHeader 3.4 kB (0) · 3.3 kB CSS (0) — — · — · —
TableRow 6.5 kB (0) · 4.0 kB CSS (0) — — · — · —
Timer 9.5 kB (0) · 5.9 kB CSS (0) — — · — · —
CommandPalette 53.5 kB (−1 B) · 12.3 kB CSS (0) — — · — · —
Timestamp 21.3 kB (−1 B) · 8.9 kB CSS (0) — — · — · —

Package size: measured; main has no measurement of the merge base to compare yet.

API changes: cli +8 · ~0 · −0 (against the merge base's committed report); core +0 · ~2 · −0 (against the merge base's committed report)

Committed API report behind this build: cli 8 rows, core 2 rows; run pnpm api:report.

10 API changes (advisory)
Package Where Signature Usage
+ cli ./api · Types · type SearchResultEntry deprecated?: ComponentDeprecation | undefined import type {SearchResultEntry} from '@astryxdesign/cli/api'; const x: SearchResultEntry = {deprecated: …}
+ cli ./authoring · Types · interface ComponentDeprecation interface ComponentDeprecation import type {ComponentDeprecation} from '@astryxdesign/cli/authoring'
+ cli ./authoring · Types · interface MultiComponentDoc deprecated?: ComponentDeprecation import type {MultiComponentDoc} from '@astryxdesign/cli/authoring'; const x: MultiComponentDoc = {deprecated: …}
+ cli ./authoring · Types · interface SingleComponentDoc deprecated?: ComponentDeprecation import type {SingleComponentDoc} from '@astryxdesign/cli/authoring'; const x: SingleComponentDoc = {deprecated: …}
+ cli ./doc · Types · interface ComponentBaseDoc deprecated?: ComponentDeprecation import type {ComponentBaseDoc} from '@astryxdesign/cli/doc'; const x: ComponentBaseDoc = {deprecated: …}
+ cli ./doc · Types · interface SubComponentDoc deprecated?: ComponentDeprecation import type {SubComponentDoc} from '@astryxdesign/cli/doc'; const x: SubComponentDoc = {deprecated: …}
+ cli ./doc · Also exported from an earlier entry point · ComponentDeprecation ComponentDeprecation (./authoring) import {ComponentDeprecation} from '@astryxdesign/cli/doc'
+ cli ./template · Also exported from an earlier entry point · ComponentDeprecation ComponentDeprecation (./authoring) import {ComponentDeprecation} from '@astryxdesign/cli/template'
~ core . · Components · component DropdownMenu prop presentation?: DropdownMenuPresentation = 'popover' → prop presentation?: DropdownMenuPresentation <DropdownMenu presentation={…} />
~ core . · Components · component MoreMenu prop presentation?: DropdownMenuPresentation = 'popover' → prop presentation?: DropdownMenuPresentation <MoreMenu presentation={…} />

Wide change (8 components): add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@cixzhang

cixzhang commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 0d966ff

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 4, 2026

@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. INV18 has an engineering owner's approval for this head and the anchor-name lifetime lives in one place in the layer runtime with red-first unit tests, but two things need fixing:

  • hide() and the browser-close branch of the toggle handler (useLayer.tsx:1486, :1627) remove the trigger's anchor name as soon as the popover closes while TopNavMegaMenu keeps its panel painting for a close fade, so for the whole fade the panel jumps to the viewport's top-left corner over the nav (in Chromium, 40 ms into the close it sits at x 16, y 62 on main and at x 0, y -2 here); keep the name until the layer has stopped painting and add a test for a layer with an exit transition.
  • The changeset and the description's User impact say "a sheet, a swipe or a keyboard ride" keeps animating, but the only reproduction moves the Storybook root around a closed Tooltip trigger, so reword it to "a transform animation on an element that contains a closed trigger keeps running while the main thread is busy" or add those cases.

Also worth a look: DropdownMenu.test.tsx:4720 and Popover.test.tsx:1678 now watch a closed, unnamed trigger, so they no longer catch a trigger ref that re-attaches during a render; opening the layer before the re-render restores that guard. CI has not run on this head (every job was skipped).

[Automated review]

Comment thread packages/core/src/Layer/useLayer.tsx Outdated
onHide?.();
}
// A closed trigger is no anchor.
if (triggerRef.current != 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.

This removes the trigger's anchor name in the same task as hidePopover, but a layer with a close fade (TopNavMegaMenu's panel transitions opacity, transform, overlay, display with allow-discrete) keeps painting for the whole fade, now with no anchor: in Chromium the panel jumps to the viewport's top-left corner over the nav. Consider removing the name only after the popover's running animations finish (and not if the layer reopened meanwhile). The same applies to the browser-close branch of the toggle handler.

'@astryxdesign/core': patch
---

[fix] A layer's trigger (Tooltip, Popover, HoverCard, DropdownMenu, ContextMenu and every other `useLayer` caller) now carries its CSS `anchor-name` only while the layer is shown. A closed trigger is no anchor, so in WebKit's Linux ports a surface that moves around it, such as a sheet, a swipe or a keyboard ride, keeps animating while the main thread is busy. If you write a layer's `anchorId` as an anchor name yourself, write it only while the layer is shown.

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.

"such as a sheet, a swipe or a keyboard ride" goes beyond what the evidence reproduces (a Web Animations translate on the Storybook root around a closed Tooltip trigger). Suggested wording: "...so in WebKit's Linux ports a transform animation on an element that contains a closed trigger keeps running while the main thread is busy."

@vjeux
vjeux force-pushed the uikit/c08-layer-anchor branch from 0d966ff to 7c79a44 Compare November 4, 2026 16:46
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 4, 2026
@cixzhang

cixzhang commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 7c79a44

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 4, 2026

@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. INV18 has an engineering owner's approval for this head, and the close-fade jump, the changeset wording and the render-stability tests from the last review are fixed; one thing still needs fixing:

  • Miss: docs/specs/components/Popover/Popover.spec.md still says "A ref binding establishes the anchor while attached" (line 155) and "Attaching the trigger ref assigns and removes the CSS anchor name used by the Layer runtime" (line 164), which the head no longer does, so please amend both lines to INV18's lifetime in this pull request (the new head then needs an engineering owner's /approve-spec again).

Also worth a look, non-blocking: a refused show() during an exit removes the name the fade still needs (useLayer.tsx:1488), and the anchorId JSDoc and changeset say "only while the layer is shown" where the ref JSDoc adds "until its exit animation ends". CI has not run on this head yet (every job was skipped).

[Automated review]

layer stops at its own root. The native event is not stopped, so document
and window listeners and light dismiss still receive it. Keyboard, focus,
input, wheel, and drag events are out of scope.
- **INV18 — Only a shown layer's trigger is an anchor.**

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.

Miss: component:Popover still describes the old lifetime: "A ref binding establishes the anchor while attached" (docs/specs/components/Popover/Popover.spec.md:155) and "Attaching the trigger ref assigns and removes the CSS anchor name used by the Layer runtime" (:164). Under INV18 a closed popover's attached trigger carries no name (this pull request's Popover.test.tsx asserts it), so please amend both lines here, for example: "While the popover is shown, and until its exit ends, the attached trigger carries the CSS anchor name used by the Layer runtime (architecture:layer-runtime INV18); detaching the trigger removes it."

Comment thread packages/core/src/Layer/useLayer.tsx Outdated
// it refuses replays once the hide's count has ended.
if (!showPopoverElement(popover)) {
// The replay anchors the trigger again; until then it is closed.
if (anchor != 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: if this layer is still fading out from an earlier close (exitRef.current != null) when the browser refuses the show, this removes the name the fade still needs, and INV18 counts an exiting layer as shown. If a hide() then cancels the replay, the panel loses its anchor for the rest of the fade. Suggest if (anchor != null && exitRef.current == null).

* The CSS anchor name to use for positioning.
* Use when you need to set anchorName manually (e.g., display:contents wrapper).
* Use when you need to set anchorName manually (e.g., display:contents wrapper),
* and set it only while the layer is shown.

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: the ref JSDoc says the trigger keeps the name "until its exit animation ends"; this line, its copies in useLayer, useTooltip and useHoverCard, and the changeset say only "while the layer is shown". A caller who follows this text unnames at close and its fading layer jumps; the ref wording fits here too.

A layer's trigger now carries its CSS anchor name only while the layer is
shown. useLayer adds it in the task that shows the layer, before
showPopover, so the first frame is placed against it; a refused show takes
it away until its replay. hide() and the browser's own close remove it once
the layer's running finite animations end, so a layer that fades out, as
TopNavMegaMenu's panel does, stays placed until its fade ends. A show, or a
trigger that attaches again, during the fade keeps the name. A trigger that
attaches while the layer is closed takes none.

Every trigger used to carry the name from mount. In WebKit's Linux ports an
element that holds an anchor runs its transform animation on the main
thread, so a transform animation on an element that contains a closed
Tooltip, Popover or menu trigger stopped for the whole of a busy task.
Mobile Safari (iOS 26.2 Simulator) and Chromium keep it running either way.

architecture:layer-runtime gains INV18 and its verification row. An
interaction spec proves, in WebKit and Chromium, that the surface keeps
moving through a 500 ms block and that a shown tooltip still follows its
trigger, and, in Chromium, that TopNavMegaMenu's panel stays placed through
its close fade. Nine useLayer unit cases cover the name's lifetime.
@vjeux
vjeux force-pushed the uikit/c08-layer-anchor branch from 7c79a44 to 42eb812 Compare November 4, 2026 17:32
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 4, 2026
@cixzhang

cixzhang commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 42eb812

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 4, 2026

@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, because its required checks are waiting for a maintainer's ci:run label. A maintainer adds the ci:run label so CI runs.

INV18 and the amended Popover record have an engineering owner's approval for this head, the earlier findings are fixed (the Popover record, the refused show during an exit, and the anchorId wording), and the new unit cases and the interaction spec fail on main and pass here in Chromium and WebKit. One small non-blocking comment suggestion is inline.

[Automated review]

}

/**
* The finite animations still running on `layer` and its content. A layer

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 restates the filter below. Keeping only the reason would read better, for example: "A layer that fades out runs these after the browser hides it. It stays placed against its anchor until they end."

@vjeux
vjeux marked this pull request as ready for review November 4, 2026 17:53
@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 18:20
@cixzhang
cixzhang marked this pull request as ready for review November 4, 2026 18:20
@cixzhang
cixzhang marked this pull request as draft November 4, 2026 18:55
@cixzhang
cixzhang marked this pull request as ready for review November 4, 2026 18:55
@cixzhang
cixzhang marked this pull request as draft November 4, 2026 19:39
@cixzhang
cixzhang marked this pull request as ready for review November 4, 2026 19: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: CI passes on this head.

The merge from main leaves this pull request's own patch unchanged. INV18 and the amended Popover record keep an engineering owner's approval for this spec content, the earlier findings stay fixed, and the unit and Chromium interaction proofs pass with main merged in. The non-blocking suggestion on the exitAnimations comment is still open.

[Automated review]

@cixzhang

cixzhang commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

/approve-spec ea25020

@cixzhang
cixzhang merged commit 5c91e81 into meta:main Nov 4, 2026
74 of 114 checks passed
@vjeux
vjeux deleted the uikit/c08-layer-anchor branch November 4, 2026 22:58
HelloOjasMutreja added a commit to HelloOjasMutreja/astryx that referenced this pull request Nov 5, 2026
main now gives a closed layer's trigger no anchor name (meta#9963), so a trigger is an anchor only while its layer is shown. The contextRef churn cases open the layer before checking the name.
cixzhang added a commit that referenced this pull request Nov 5, 2026
…rd ends above it (#8208)

* fix(core): an anchored layer ends above the software keyboard

On iOS 26.2 a popover that would run under the software keyboard keeps
its top on its source and shrinks so its far edge stays 10 pt above the
keyboard; its content scrolls, and it grows back when the keyboard goes
down. On main the keyboard covers the lower part of any anchored layer
(a Popover, a menu, a Selector's list), and a button there cannot be
reached until the keyboard is dismissed.

The layer runtime now caps every open anchor-mode layer.
useLayerKeyboardClearance, imported through the runtime's touch module
LayerTouch.ts, reads the keyboard module's one height
(getKeyboardHeight, and the layout guide for timing). It writes the
room above the keyboard as a custom property on the layer's own
element. The runtime's block-size cap (layerViewportInset.maxBlockSize)
folds it in, so the layer box and every surface capped by that
definition shrink together. A layer nested in a capped one sets its own
value, so it is not clamped.

- Timing: a rising keyboard covers the difference on its way up, so the
  cap comes when it has arrived: UIKit's notification duration after it
  started, or the end of Gboard's slide in Chrome. A falling one takes
  it off at once, and a keyboard that changes at once is followed at
  once. A change under a press inside the layer waits for its click,
  through the shared wait for the browser's click.
- A layer opened with the keyboard up is capped in the frame before its
  first paint. Its box is read with settledBox, as the fallback order
  reads it: without the entrance transform. Only a layer whose committed
  element carries data-layer-anchored is capped.
- A layer element the runtime swaps in while open is measured again from
  its own box before it paints: the runtime's layer ref callback hands
  it to the cap. The viewport is read in layout px.
- The Selector, MultiSelector, Typeahead, Breadcrumbs and ContextMenu
  lists cap their 300 px at the layer's block-size cap. A panel with a
  search field is a flex column capped as a whole.
- Left as they are: a layer clear of the keyboard, a layer whose bottom
  the fallback order holds (above its trigger), and a layer in custom or
  fixed positioning.
- A menu's on-demand sheet keeps its keyboard code on demand: the cap
  imports the keyboard module's own files (lazy-sheet-bundle test).

* Merge main into uikit/c26-popover-keyboard

Main's #9963 adds exitAnimations to useLayer.tsx, next to the transform
helpers this branch moved to settledBox.ts. The merge keeps the move and
main's new helper.

* fix(core): a popover opened over the keyboard clips from its first frame

A popover opened while a software keyboard was up took its cap in a
frame callback the open scheduled. Its surface became a scroll
container only once its own overflow measure ran, a frame or more
after the cap. Between the two, its content painted past its shorter
box, down to the keyboard.

The cap now commits in a microtask right after the open's commit, in
the task that opens the layer. The runtime has shown the layer by
then, and a read places it, as the fallback order's read does. Each
layer also writes the overflow its surface takes beside the cap:
`auto` while capped, `visible` otherwise. The surface reads it, so it
scrolls from the commit that caps it.

* Merge branch 'main' into uikit/c26-popover-keyboard

* Merge branch 'main' into uikit/c26-popover-keyboard

* fix(core): the keyboard cap's custom properties are private

The layer runtime writes the software keyboard's cap, and the overflow
a capped surface takes, as custom properties on each layer's element.
Their public names made them rows of Core's stylesheet API, though no
app or theme sets them. They are runtime state, so they take private
names: --_layer-keyboard-max-block-size and --_layer-keyboard-overflow.
No behavior changes.

Two comment notes: the cap's comment names the one surface that reads
the overflow, and Popover's file header drops a line that repeated the
layer runtime's.

Co-authored-by: Cindy Zhang <[email protected]>
cixzhang added a commit that referenced this pull request Nov 8, 2026
…ore showing (#5398)

* fix(HoverCard,Tooltip): wait for the trigger to have a layout box before showing

* fix(Layer): treat an empty anchor box as ready; restore main's SheetWithHoverTip story

* fix(Layer): wait for the anchor through the shared resize and mutation observers

The anchor wait in show() created its own ResizeObserver and MutationObserver. Route it through observeResize and observeMutations, which architecture:react-component-runtime INV16 requires callers to use. The IntersectionObserver and the dialog toggle listener stay.

* test(Layer): the focus-return harness uses a stable trigger ref

The harness attached the trigger with an inline ref, which detaches and
reattaches it on every render. Each detach now defers its anchor-name removal
by a microtask, so the replay test, which holds the ledger's microtasks by
hand, held those too. A stable ref leaves it holding only the ledger's.

* fix(Layer): clear the strict-lint findings in the anchor-readiness comments and test harness

The new comments no longer cite an issue number or an invariant id, and the focus-return harness lists the two refs it reads in its callback's dependencies.

* test(Layer): the anchor-readiness browser spec imports Playwright through a11y-spec

main's no-restricted-imports rule (#9811) rejects @playwright/test in browser specs, so the spec imports expect, test and Page from @astryxdesign/a11y-spec/playwright, whose test keeps every browser context off remote hosts.

* test(Layer): the anchor-name churn cases show the layer first

main now gives a closed layer's trigger no anchor name (#9963), so a trigger is an anchor only while its layer is shown. The contextRef churn cases open the layer before checking the name.

* fix(Layer): the anchor settle waits only on document-timeline animations, through one shared predicate

A scroll- or view-driven animation finishes only when the person scrolls to the end of its range, so a controlled Tooltip inside such an ancestor stayed hidden. The settle wait now skips animations not on the document's timeline, and it shares the running-and-finite test with exitAnimations.

* docs(Layer): the anchor-wait changeset and comments describe the document-timeline wait

The changeset and the comments still described a wait on any running finite animation. They now say it waits on running animations on the document timeline that end on their own, and not on paused, infinite, or scroll- and view-driven ones.

* Merge branch 'main' into fix/hovercard-controlled-open-anchoring

* chore(lint): regenerate the comment-provenance baseline

The useLayer.tsx comments no longer cite INV6/FR4 or quote a requirement, so
the baseline drops those three sites.

* Merge main into fix/hovercard-controlled-open-anchoring

Resolves useLayer.tsx's imports: keeps both this branch's shared resize
and mutation observers and main's flat-tree, shadow-root and input-stream
helpers.

* review: comment wording and a churn guard that fails on main

- The churn test records every write to the trigger's style, so it fails
  when a null-then-same-element reattach removes and re-adds the anchor
  name (main) even though the name ends up present.
- The isAnchorReady doc sits on isAnchorReady; isShownAsPopover gets its
  own line. The anchor-wait comments say "no layout box" rather than 0x0,
  the unmount note names the released anchor wait, and the contextRef
  comment keeps its reason in a few sentences.

* Merge branch 'main' into fix/hovercard-controlled-open-anchoring

Co-authored-by: Cindy Zhang <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — ea250201 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants