Skip to content

fix(Layer): keep a flush layer's entrance off its trigger - #11417

Merged
cixzhang merged 2 commits into
meta:mainfrom
vjeux:fix/layer-entrance-flush-no-slide
Nov 12, 2026
Merged

cixzhang merged 2 commits into
meta:mainfrom
vjeux:fix/layer-entrance-flush-no-slide

Conversation

@vjeux

@vjeux vjeux commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

An anchored layer flush against its trigger, or over its edge, no longer slides over it as it enters. Red-first: yes, two unit cases fail on main.

User impact

People whose app shows an anchored layer at offset 0, useLayer's default, or a negative offset, against a sized trigger, with motion allowed. Its entrance started one 8 px step toward the trigger, so its first frames covered the trigger. A menu opened at the pointer, whose anchor is a 1 px point, keeps its step.

Problem and solution fit

An entrance's step stops at the room between the layer and its trigger. A flush or overlapping layer has no room, but the runtime wrote no gap for it, so the keyframes fell back to the whole step.

The runtime now writes 0 px for a sized anchor with no room. The step is then 0, and the entrance scales in place, as it does for a layer over its trigger. A point anchor, at most a pixel each way like a menu's cursor anchor, has no gap, so its layer keeps the whole step.

Expected behavior and authority

  • architecture:layer-runtime INV20: an entrance starts from the side its layer lands on, "So it never slides onto its trigger."
  • INV20 names one layer that does not slide: a layer that covers its trigger's center.

Smallest restoration

layerEntranceSide.ts writes the gap for a sized anchor even when it is 0, and none for a point anchor. INV20's verification row names the new unit cases. No public API or default changes.

Evidence

  • Reproduction before the change: the two new unit cases fail on main 91cd63f.
  • Result after the change, at f5b19a1: they pass.
  • Representative unchanged path: the entrance-side spec passes for every anchored layer it opens, the menu at the pointer included, in Chromium and WebKit.
  • Regression test or other mutation-sensitive proof: unit cases for a flush layer, room under 0.001 px, and 0 and 1 px points.

Scope

Components: Layer, and every anchored layer's entrance

  • 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

All runs below are at 370e538, on a Storybook built at it. This PR's head, f5b19a1, changes only comments, a test title, the changeset and INV20's verification row. CI runs the a11y specs in Chromium only, so the WebKit runs are by hand, in the CI-profile WebKit container.

Run Engine Result
LayerEntranceSide.interaction.browser.spec.ts Chromium 20 passed
The same WebKit 20 passed
TooltipTallContent.a11y.browser.spec.ts Chromium 13 passed
The same WebKit 13 passed
  • layerEntranceSide.test.ts: 10 tests pass. Against main's layerEntranceSide.ts, the two new cases fail and the other 8 pass.
  • pnpm exec vitest run --project ui: 1,006 files, 24,800 tests pass.
  • @astryxdesign/core typecheck: 0 errors. ESLint and Prettier on the changed files: clean. pnpm check:knowledge: aligned.
  • No Core layer sits flush against a sized trigger: each passes --spacing-1 or a margin of that size. So the visible change is for an app's own layers at offset 0.
  • A first version treated only a 0 px anchor as a point. The entrance-side spec failed ContextMenu in both engines, whose cursor anchor is 1 px, so a point is now at most a pixel each way.

Public and internal API delta

Public: none.

Internal, changed: LayerEntranceSide.gap becomes number | null. It is null for a point anchor, at most a pixel each way, such as a menu's cursor anchor. writeLayerEntranceSide writes initial for null, so that layer keeps the whole step, and 0px for a flush sized anchor.
Usage: const {gap} = layerEntranceSide(layerBox, anchorBox);

No new module or hook: the change stays in layerEntranceSide.ts.

Lines: product +40/−29 (layerEntranceSide.ts), tests +20/−6, changeset +7/−0, record +1/−1.

App-level size: a minimal Vite app that renders a Popover and a ContextMenu, built for production. Its eager gzip grows by 22 B of JS against main 91cd63f, and its CSS is unchanged. JS goes from 271,745 to 271,767 B.

Writing rubric results

R1 narration: none; the INV20 verification row states what each check covers, in the present tense.
R2 research: none in the record.
R3 evidence: the row names unit cases and specs, not a pull request.
R4 rejected alternatives: none.
R5 change references: none.
R6 open questions: none.
R7 project status: none.

A layer flush against a sized trigger, or over its edge, took the
whole 8 px step, so its first frame covered the trigger. Its room is
now 0 px, and the step stops there: the entrance scales in place. A
point anchor, at most a pixel each way like a menu's cursor anchor,
has no gap, so that menu keeps its step.
INV20's verification row names the unit cases for a step that stops
at the room to a sized trigger, and for no step when flush or over.
@vercel

vercel Bot commented Nov 12, 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 12, 2026 6:09pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 12, 2026
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 12, 2026
@astracat-bot

astracat-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

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

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

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · f5b19a1

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
LayerProvider 4.4 kB (0) · 20 B CSS (0) — ✓ · ✓ · ✗
lab/EmojiPicker 90.8 kB (+29 B) · 751 B CSS (0) — — · — · —
ChatComposer 83.2 kB (+26 B) · 12.4 kB CSS (0) — — · — · —
115 more components
Component Size LoC Visual · A11y · RTL
MobileNav 74.4 kB (+26 B) · 11.0 kB CSS (0) — — · — · —
Stepper 65.6 kB (+26 B) · 10.5 kB CSS (0) — — · — · —
BaseTypeahead 77.0 kB (+25 B) · 11.3 kB CSS (0) — — · — · —
FieldLabel 54.7 kB (+25 B) · 5.8 kB CSS (0) — — · — · —
ChatDictationButton 64.4 kB (+24 B) · 10.4 kB CSS (0) — — · — · —
ChatLayoutScrollButton 64.4 kB (+24 B) · 10.5 kB CSS (0) — — · — · —
InputGroup 60.2 kB (+24 B) · 7.9 kB CSS (0) — — · — · —
RadioList 59.9 kB (+23 B) · 7.3 kB CSS (0) — — · — · —
SideNavCollapseButton 64.7 kB (+23 B) · 10.4 kB CSS (0) — — · — · —
TopNav 76.1 kB (+23 B) · 11.3 kB CSS (0) — — · — · —
lab/Comments 360.8 kB (+23 B) · 2.5 kB CSS (0) — — · — · —
Calendar 74.9 kB (+22 B) · 11.0 kB CSS (0) — — · — · —
DialogHeader 66.7 kB (+22 B) · 11.9 kB CSS (0) — — · — · —
MobileNavToggle 64.2 kB (+22 B) · 10.3 kB CSS (0) — — · — · —
TextArea 66.0 kB (+22 B) · 9.4 kB CSS (0) — — · — · —
IconButton 63.9 kB (+21 B) · 10.3 kB CSS (0) — — · — · —
Link 55.6 kB (+21 B) · 7.1 kB CSS (0) — — · — · —
Button 63.9 kB (+20 B) · 10.3 kB CSS (0) — — · — · —
CodeBlock 79.1 kB (+20 B) · 11.6 kB CSS (0) — — · — · —
Field 58.6 kB (+20 B) · 7.3 kB CSS (0) — — · — · —
AppShell 95.7 kB (+19 B) · 13.8 kB CSS (0) — — · — · —
AvatarGroupOverflow 51.2 kB (+19 B) · 5.7 kB CSS (0) — — · — · —
Banner 65.9 kB (+19 B) · 10.9 kB CSS (0) — — · — · —
Popover 96.1 kB (+19 B) · 14.6 kB CSS (0) — — · — · —
Switch 108.0 kB (+19 B) · 10.0 kB CSS (0) — — · — · —
lab/DialogHeroHeader 87.0 kB (+19 B) · 372 B CSS (0) — — · — · —
ChatSendButton 64.3 kB (+18 B) · 10.3 kB CSS (0) — — · — · —
CheckboxList 72.3 kB (+18 B) · 7.8 kB CSS (0) — — · — · —
ComplexSelector 76.2 kB (+18 B) · 12.2 kB CSS (0) — — · — · —
DrawerHeader 66.9 kB (+18 B) · 13.3 kB CSS (0) — — · — · —
FileInput 72.8 kB (+18 B) · 11.3 kB CSS (0) — — · — · —
lab/TransferList 106.2 kB (+18 B) · 1.2 kB CSS (0) — — · — · —
AvatarGroup 48.1 kB (+17 B) · 5.8 kB CSS (0) — — · — · —
ChatComposerInput 80.9 kB (+17 B) · 11.7 kB CSS (0) — — · — · —
ChatComposerTokenElement 80.9 kB (+17 B) · 11.7 kB CSS (0) — — · — · —
NumberInput 75.4 kB (+17 B) · 11.8 kB CSS (0) — — · — · —
RadioListItem 71.2 kB (+17 B) · 10.4 kB CSS (0) — — · — · —
SideNavItem 75.6 kB (+17 B) · 11.5 kB CSS (0) — — · — · —
TextInput 71.5 kB (+17 B) · 11.5 kB CSS (0) — — · — · —
TimeInput 168.7 kB (+17 B) · 16.4 kB CSS (0) — — · — · —
lab/CommentPin 59.6 kB (+17 B) · 1.2 kB CSS (0) — — · — · —
lab/DiffViewer 91.4 kB (+17 B) · 2.1 kB CSS (0) — — · — · —
lab/TransferListSelector 114.9 kB (+17 B) · 1.4 kB CSS (0) — — · — · —
BreadcrumbItem 90.2 kB (+16 B) · 12.5 kB CSS (0) — — · — · —
CheckboxListItem 74.9 kB (+16 B) · 11.7 kB CSS (0) — — · — · —
Pagination 115.9 kB (+16 B) · 18.2 kB CSS (0) — — · — · —
PowerSearch 301.1 kB (+16 B) · 24.7 kB CSS (0) — — · — · —
Thumbnail 68.2 kB (+16 B) · 11.9 kB CSS (0) — — · — · —
Tooltip 31.5 kB (+16 B) · 4.5 kB CSS (0) — — · — · —
TopNavHeading 80.6 kB (+16 B) · 11.6 kB CSS (0) — — · — · —
lab/ListInput 92.0 kB (+16 B) · 922 B CSS (0) — — · — · —
lab/SelectableCardGroup 67.9 kB (+16 B) · 162 B CSS (0) — — · — · —
AlertDialog 109.9 kB (+15 B) · 15.0 kB CSS (0) — — · — · —
InfoTip 49.7 kB (+15 B) · 5.4 kB CSS (0) — — · — · —
ListItem 74.1 kB (+15 B) · 11.7 kB CSS (0) — — · — · —
TabMenu 77.3 kB (+15 B) · 11.5 kB CSS (0) — — · — · —
Toolbar 46.5 kB (+15 B) · 8.1 kB CSS (0) — — · — · —
lab/TabBarMoreList 96.4 kB (+15 B) · 1.8 kB CSS (0) — — · — · —
charts/ChartTooltip 187.4 kB (+14 B) · 451 B CSS (0) — — · — · —
ChatLayout 87.1 kB (+14 B) · 10.9 kB CSS (0) — — · — · —
DropdownMenu 102.7 kB (+14 B) · 17.9 kB CSS (0) — — · — · —
MoreMenu 102.9 kB (+14 B) · 17.9 kB CSS (0) — — · — · —
Selector 105.7 kB (+14 B) · 17.9 kB CSS (0) — — · — · —
SideNav 119.1 kB (+14 B) · 11.7 kB CSS (0) — — · — · —
SideNavHeading 81.0 kB (+14 B) · 11.7 kB CSS (0) — — · — · —
TableSelectionToolbar 74.1 kB (+14 B) · 13.6 kB CSS (0) — — · — · —
lab/CommentThread 354.1 kB (+14 B) · 2.4 kB CSS (0) — — · — · —
DropdownMenuSubMenu 73.6 kB (+13 B) · 10.1 kB CSS (0) — — · — · —
HoverCard 29.7 kB (+13 B) · 4.5 kB CSS (0) — — · — · —
Markdown 193.9 kB (+13 B) · 21.1 kB CSS (0) — — · — · —
TopNavMegaMenu 74.8 kB (+13 B) · 12.2 kB CSS (0) — — · — · —
Typeahead 86.2 kB (+13 B) · 12.8 kB CSS (0) — — · — · —
Carousel 73.5 kB (+12 B) · 11.3 kB CSS (0) — — · — · —
CheckboxInput 68.0 kB (+12 B) · 10.1 kB CSS (0) — — · — · —
DateInput 194.6 kB (+12 B) · 17.4 kB CSS (0) — — · — · —
MultiSelector 100.0 kB (+12 B) · 17.2 kB CSS (0) — — · — · —
Table 130.9 kB (+12 B) · 18.7 kB CSS (0) — — · — · —
Tokenizer 102.4 kB (+12 B) · 19.5 kB CSS (0) — — · — · —
richtext/RichTextEditor 302.7 kB (+12 B) · 2.6 kB CSS (0) — — · — · —
richtext/RichTextView 280.4 kB (+12 B) · 2.3 kB CSS (0) — — · — · —
Avatar 45.3 kB (+11 B) · 5.7 kB CSS (0) — — · — · —
Slider 113.5 kB (+11 B) · 8.9 kB CSS (0) — — · — · —
ToggleButton 90.8 kB (+11 B) · 10.4 kB CSS (0) — — · — · —
lab/ChatEmojiPicker 111.4 kB (+11 B) · 773 B CSS (0) — — · — · —
lab/ChatReactionBar 112.6 kB (+11 B) · 1.1 kB CSS (0) — — · — · —
lab/TourStep 102.4 kB (+11 B) · 590 B CSS (0) — — · — · —
CommandPalette 75.4 kB (+10 B) · 12.7 kB CSS (0) — — · — · —
ContextMenu 113.5 kB (+10 B) · 17.8 kB CSS (0) — — · — · —
DateRangeInput 97.9 kB (+10 B) · 12.9 kB CSS (0) — — · — · —
DateTimeInput 217.1 kB (+10 B) · 19.1 kB CSS (0) — — · — · —
SegmentedControl 101.3 kB (+10 B) · 6.9 kB CSS (0) — — · — · —
StatusDot 33.2 kB (+10 B) · 5.4 kB CSS (0) — — · — · —
TabList 46.7 kB (+10 B) · 6.5 kB CSS (0) — — · — · —
lab/CommentComposer 157.2 kB (+10 B) · 1.9 kB CSS (0) — — · — · —
Lightbox 127.8 kB (+9 B) · 10.9 kB CSS (0) — — · — · —
richtext/RichTextEditorToolbar 285.0 kB (+9 B) · 454 B CSS (0) — — · — · —
charts/Chart 210.3 kB (+8 B) · 516 B CSS (0) — — · — · —
TableCell 114.8 kB (+8 B) · 18.3 kB CSS (0) — — · — · —
TopNavMenu 80.0 kB (+8 B) · 11.6 kB CSS (0) — — · — · —
Toast 102.0 kB (+7 B) · 10.6 kB CSS (0) — — · — · —
lab/Schedule 110.6 kB (+7 B) · 3.9 kB CSS (0) — — · — · —
TableHeaderCell 114.3 kB (+6 B) · 18.0 kB CSS (0) — — · — · —
ChatToolCalls 34.4 kB (+1 B) · 8.4 kB CSS (0) — — · — · —
Text 13.8 kB (+1 B) · 5.5 kB CSS (0) — — · — · —
lab/LineClamp 16.0 kB (+1 B) · 168 B CSS (0) — — · — · —
CommandPaletteInput 33.9 kB (0) · 7.6 kB CSS (0) — — · — · —
Timer 15.9 kB (0) · 6.1 kB CSS (0) — — · — · —
Timestamp 35.3 kB (0) · 10.6 kB CSS (0) — — · — · —
charts/ChartLegend 53.9 kB (−1 B) · 224 B CSS (0) — — · — · —
ChatMessageList 30.2 kB (−1 B) · 7.1 kB CSS (0) — — · — · —
Heading 14.4 kB (−1 B) · 5.5 kB CSS (0) — — · — · —
ProgressBar 12.0 kB (−1 B) · 6.4 kB CSS (0) — — · — · —
Spinner 26.8 kB (−1 B) · 6.3 kB CSS (0) — — · — · —
layer — — — · ✓ · —
Layer — — ✓ · ✓ · —

Package size: @astryxdesign/core 7.41 MB packed (+259 B); no new dependencies.

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

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec f5b19a1

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 12, 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. It runs once the pull request leaves draft and a maintainer adds the ci:run label, because the branch is in a fork.

The change restores layer-runtime INV20 ("So it never slides onto its trigger") for a layer flush against, or over the edge of, a sized trigger. The two new unit cases fail against main and pass on this head, and no other anchored layer's entrance step changes. Two optional suggestions are left inline: a point anchor that its layer sits clear of now loses the step cap it had on main, and one comment overstates the cap.

Claims and files checked
  • Changeset: a layer flush against its trigger, or over its edge, no longer slides over it: verified in layerEntranceSide.ts and the new unit cases.
  • Changeset: its entrance scales in place, like a layer over its trigger's center: verified, because the step is 0 and the scale stays.
  • Changeset: a menu at the pointer still slides from its side: verified, because the 1 px cursor anchor counts as a point.
  • Description: two new unit cases fail on main and pass here: verified by replaying the test file's assertions against both implementations (8 of 10 on main, 10 of 10 here).
  • Description: the entrance used to start one 8 px step toward the trigger: verified (--spacing-2 cap in layerAnimations.stylex.ts).
  • Description: the affected layers sit at offset 0, the hook's default, or a negative offset against a sized trigger: verified; they must also play the shared layerAnimations entrance.
  • Description: zero room is now written as 0 px for a sized anchor, and a point keeps the whole step: verified, with one unmentioned case noted inline (a point with room).
  • Description: the layer-runtime INV20 quotes match the record: verified.
  • Description: no public API or default changes, and no new module or hook: verified.
  • Description: no Core layer sits flush against a sized trigger: verified (each passes --spacing-1, sits over the trigger's center, or opens at a 1 px point).
  • Description: the head differs from the commit that was tested only in comments, a test title, the changeset and the verification row: verified.
  • Description: the line counts and the writing-rubric results: verified.
  • Description: the browser specs in Chromium and WebKit, the full unit suite, typecheck, ESLint, Prettier, the knowledge check and the bundle-size measurement: not reproduced in this review; CI repeats the repository checks once it runs.
  • File packages/core/src/Layer/layerEntranceSide.ts: two optional suggestions (inline).
  • File packages/core/src/Layer/layerEntranceSide.test.ts: clear.
  • File .changeset/layer-entrance-flush-no-slide.md: clear.
  • File docs/architecture/layer-runtime.md: clear.

Automated review (maintainer link)

const anchorY = anchor.top + anchor.height / 2;
const originX = clamp(anchorX - layer.left, layer.width);
const originY = clamp(anchorY - layer.top, layer.height);
const isPoint = anchor.width <= 1 && anchor.height <= 1;

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.

Optional: gap is null for any anchor of at most 1 px each way, even when the layer sits clear of it. A useLayer layer at a positive offset from such an anchor now takes the whole 8 px step across it, where main stopped at the room: with 3 px of room, main writes 3px and this head writes initial. No Core layer reaches this, because ContextMenu opens at offset 0. If it is not intended, compute the signed room once and keep it when it is positive:

const room = below
  ? layer.top - (anchor.top + anchor.height)
  : anchor.top - (layer.top + layer.height);
// ...
gap: isPoint && room <= 0 ? null : Math.max(0, room),

Comment on lines +56 to +57
* room between the two on the step's axis. The step never goes past it, so no
* frame of the entrance covers a sized anchor. A layer flush against or over

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.

Optional: "no frame of the entrance covers a sized anchor" does not hold for a layer that already overlaps its anchor, the submenu case this comment names, because that layer covers those pixels in every frame. Suggested: "The step never goes past it, so the entrance never covers more of a sized anchor than the settled layer does."

@vjeux
vjeux marked this pull request as ready for review November 12, 2026 18:46
@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 12, 2026
@cixzhang
cixzhang marked this pull request as draft November 12, 2026 19:17
@cixzhang
cixzhang marked this pull request as ready for review November 12, 2026 19:17
@cixzhang
cixzhang merged commit 0e8c961 into meta:main Nov 12, 2026
189 of 194 checks passed
@vjeux
vjeux deleted the fix/layer-entrance-flush-no-slide branch November 12, 2026 20:16

This branch was successfully deployed

1 active deployment
Preview — f5b19a14 Deployed Nov 12, 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