Repository navigation
refactor(Layer): one presentation hold keeps a layer's chosen presentation until its close settles - #8587
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| LayerProvider | 4.2 kB (0) · 20 B CSS (0) | — | ✓ · ✓ · ✗ |
| lab/Comments | 322.8 kB (+180 B) · 2.5 kB CSS (0) | — | — · — · — |
| Popover · Storybook | 87.4 kB (+178 B) · 13.9 kB CSS (0) | 1,509 (+2) | ✓ · ✓ · ✓ |
7 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| lab/ChatReactionBar | 103.0 kB (+172 B) · 1.1 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 143.8 kB (+159 B) · 1.9 kB CSS (0) | — | — · — · — |
| lab/TourStep | 93.7 kB (+152 B) · 590 B CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 101.8 kB (+144 B) · 773 B CSS (0) | — | — · — · — |
| lab/CommentThread | 317.8 kB (+135 B) · 2.4 kB CSS (0) | — | — · — · — |
| layer | — | — | — · ✓ · — |
| Layer | — | — | ✓ · ✓ · — |
Package size: @astryxdesign/core 6.90 MB packed (+3.0 kB); no new dependencies.
API changes: none in this pull request
Committed API report behind this build: cli 21 rows, core 25 rows; 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
There was a problem hiding this comment.
This can't be approved yet: it needs an engineering owner's decision on a spec addition, and three changes. Through the stacked exit-copy work, the diff against main adds INV13 ("One exit copy per closing layer") to the current architecture:layer-runtime record. An engineering owner records approval or rejection by commenting /approve-spec followed by the full head commit SHA on this pull request, and the author may do so if they are an engineering owner.
- Land the parent pull requests (#8187, #8342 and the stack beneath them) and rebase, or retarget the base, so the diff carries only the 295-line presentation-hold commit instead of 38,390 authored lines.
- Add
touchHoldto theuseCallbackdependency list atpackages/core/src/Popover/usePopoverSurfaceMotion.ts:134, which currently fails the Lint check. - Update the Current gaps paragraph and Owning code in
docs/architecture/layer-runtime.md, which still say no shared presentation hold exists and that Popover builds its own.
[Automated review]
|
/approve-spec 99b0ba8 |
There was a problem hiding this comment.
One small change is needed before approval: this pull request edits docs/architecture/layer-runtime.md, so please add a ## Writing rubric results section to the description with one line for each of R1–R6 from docs/contributing/spec-writing.md. The code needs no changes: Popover's three latches move onto the internal presentation hold with no behavior change, the Layer and Popover tests pass, Chromium renders the sheet and touch states exactly as before, and the record change is approved at this head. The failed Review signal job refused a stale 208-file count, so re-running it should publish review-required for this head.
[Automated review]
There was a problem hiding this comment.
This looks ready to approve: Popover's three presentation latches move onto the layer runtime's internal presentation hold with no behavior change, the unchanged Layer and Popover tests pass, Chromium renders the sheet and touch states exactly as before, and the record change is approved at this head with the writing rubric results now in the description. One housekeeping step remains: the Review signal check failed on a stale 208-file count when the base changed, so re-running it should publish review-required for this head.
[Automated review]
…ation until its close settles architecture:layer-runtime INV14 gives the layer runtime the presentation hold: keeping a layer's chosen presentation from the open until the close settles. Layer/presentationHold.ts (internal) is that one job: createPresentationHold for code that chooses at an open event, and usePresentationHold for a choice taken during render; the component releases it when its close settles. Popover adopts it for its three latches, with no behavior change: the controlled surface (taken as isOpen turns on, let go as it turns off), the sheet kept mounted until its dialog has closed, and the touch-or-pointer presentation its close plays in (usePopoverSurfaceMotion). Not the input hold (inputHold.ts). Not exported; a test locks that. Co-authored-by: Christopher Chedeau <[email protected]> # Conflicts: # packages/core/src/Popover/Popover.tsx # packages/core/src/Popover/usePopoverSurfaceMotion.ts
…the record names the shared hold usePopoverSurfaceMotion's returned callback reads touchHold, so it is in its dependency list (lint). architecture:layer-runtime's current-gaps paragraph no longer says no shared presentation hold exists or that Popover builds its own: the runtime owns it (Layer/presentationHold.ts) and Popover uses it; Owning code and verified_by name it. # Conflicts: # docs/architecture/layer-runtime.md # packages/core/src/Popover/usePopoverSurfaceMotion.ts
…iting the record The record links the file through its Owning code and verified_by, so the header drops the record and claim citation the comment-provenance rule refuses.
99b0ba8 to
cf409fc
Compare
|
/approve-spec cf409fc |
There was a problem hiding this comment.
Changes requested: the refactor itself is sound, but three spec records still describe the shared presentation hold as missing.
- Regression:
docs/specs/components/Popover/Popover.spec.mdline 196 (FR9's state),docs/specs/components/PowerSearch/PowerSearch.spec.mdline 262 (FR10) anddocs/specs/components/Tokenizer/Tokenizer.spec.mdline 244 (FR16) still say the layer runtime has no shared presentation hold, which contradicts the updatedarchitecture:layer-runtimerecord, so please set FR9's state to "Implemented" and say in the other two that the runtime's hold isLayer/presentationHold.tsand the field keeps its own until it adopts it.
Popover's existing tests pass unchanged and catch a broken hold, and the new module stays internal. The inline suggestions on the new comments are optional. A new commit needs a fresh /approve-spec <full head SHA> from an engineering owner, which the author may record as one.
[Automated review]
| /** | ||
| * @file presentationHold.ts | ||
| * @input Whether a layer is open, and the presentation an opening would | ||
| * choose now | ||
| * @output createPresentationHold (an imperative hold, for code that decides | ||
| * at an open event) and usePresentationHold (the same hold taken during | ||
| * render): the presentation the opening chose, held until the component | ||
| * releases it | ||
| * @position The layer runtime's presentation hold: it keeps a layer's chosen | ||
| * presentation from the open until its close settles. Internal to core: not | ||
| * exported from the package or any barrel (presentationHold.test.tsx locks | ||
| * that). Not the input hold (inputHold.ts), which drops input while a | ||
| * presentation animates. | ||
| * | ||
| * A layer that can present more than one way (a popover that is a sheet on a | ||
| * phone, a touch grow or a pointer entrance) chooses as it opens, and its | ||
| * close has to play out in the same presentation even when what it would | ||
| * choose has changed meanwhile (a phone rotated past the compact width, a | ||
| * pointer that changed). One job: take the choice at the opening, hold it, | ||
| * and let it go when the component says its close has settled (its | ||
| * `<dialog>`'s `close` event, its exit animation's end). The component | ||
| * decides when that is; the hold decides nothing about timing. | ||
| * | ||
| * SYNC: When modified, update presentationHold.test.tsx. | ||
| */ |
There was a problem hiding this comment.
Optional (INV29): this header runs 25 lines, about twice the limit, and @output repeats the hook's JSDoc. A shorter header can keep only the reason:
/**
* @file presentationHold.ts
* @input Whether a layer is open, and the presentation it would choose now
* @output createPresentationHold and usePresentationHold
* @position The layer runtime's presentation hold. Internal to core. It is
* not the input hold (inputHold.ts).
*
* A close plays in the presentation that its open chose. The component
* releases the hold when its close settles.
*
* SYNC: When modified, update presentationHold.test.tsx.
*/| // The layer runtime's presentation hold (Layer/presentationHold), taken | ||
| // during render as the controlled `isOpen` turns on, so the open surface is | ||
| // known in the same render that opens it, and let go as it turns off. |
There was a problem hiding this comment.
Optional (INV29): this is one 37-word sentence that names the module and covers both the take and the release. Suggested:
// The hold is taken during render. The render that opens the popover then
// knows its surface.| // The sheet's presentation hold: from the render that opens it until its | ||
| // dialog has closed. |
There was a problem hiding this comment.
Optional (INV29): this restates usePresentationHold({isOpen: isSheetOpen, …}) and the comment above, which already says the sheet stays until its dialog has closed. It can go.
| // Whether the presentation in progress is the touch one, held from the | ||
| // open until its close begins (Layer/presentationHold). |
There was a problem hiding this comment.
Optional (INV29): "(Layer/presentationHold)" restates the import. Suggested:
// True while the presentation in progress is the touch one, until its close
// begins.…ime's presentation hold Popover FR9's open-to-close latch uses the shared hold, so its gap closes. PowerSearch FR10 and Tokenizer FR16 keep their own holds; their INV14 gap now says the runtime provides one and the field has yet to adopt it.
|
/approve-spec e75ef3d |
There was a problem hiding this comment.
Approved pending CI: the required test, build and docsite-test checks were stopped on this head because CI was full, so they have not run yet; re-run all jobs before this merges.
The Popover, PowerSearch and Tokenizer records now name the layer runtime's presentation hold, which resolves the earlier change request. Popover's existing tests pass unchanged, its sheet, touch and mouse presentations render the same before and after, and the hold stays internal. The earlier inline suggestions on the new comments remain optional.
[Automated review]
#8587 (the layer runtime's presentation hold) merged as a squash, so this takes main for everything outside MobileNav and keeps only MobileNav's adoption: main's MobileNav, including the shared scroll lock, with its close hold moved onto usePresentationHold.
The presentation hold (#8587) merged into main, so this branch now targets main. The Selector adoption's own diff is unchanged.
Retargeted to
main: both bases (#8187, Popover's touch presentation; #8342, the input hold) are merged. A maintainer replayed this pull request's two commits onto currentmain(authorship kept) and resolved them against Popover's newer code.What it does
One internal module with one job, the layer runtime's presentation hold (
architecture:layer-runtimeINV14): keep a layer's chosen presentation from the open until its close settles.packages/core/src/Layer/presentationHold.ts:usePresentationHold({isOpen, presentation}) → {presentation, isHeld, release}. The render in whichisOpenturns on holdspresentationas it is then. It stays held, whateverpresentationbecomes, until the component callsrelease()when its close has settled.createPresentationHold(): the same hold for code that chooses at an open event (take,current,isHeld,release).It decides nothing about timing; the component says when its close has settled. It isn't the input hold (
inputHold.ts, which drops input while a presentation animates). It isn't exported from the package or the Layer barrel (presentationHold.test.tsxlocks that). It contains no component names.Record
architecture:layer-runtime's current-gaps paragraph no longer says no shared presentation hold exists or that Popover builds its own; Owning code andverified_bynameLayer/presentationHold.ts. INV14 itself is unchanged.Writing rubric results
R1 narration: none; the current-gaps sentence and the Owning code entry state what the runtime owns now, in the present tense.
R2 research: none in the record.
R3 evidence: no evidence, basis or verification cell changed;
verified_bynames a test file.R4 rejected alternatives: none added.
R5 change references: none.
R6 open questions: none touched.
Second pass, after the Popover, PowerSearch and Tokenizer records were edited (one gap sentence each):
R1 narration: none; each sentence states the current gap in the present tense.
R2 research: none. R3 evidence: no evidence cell changed. R4 rejected alternatives: none. R5 change references: none. R6 open questions: none.
First adopter: Popover
All three of Popover's latches move onto it:
isOpenturns on, let go as it turns off, so a phone rotated past the compact width keeps its sheet while open.<dialog>closes.usePopoverSurfaceMotion, which now reads the shared touch resolverisCoarsePointer): taken at the open, read and let go as the close begins.Other components adopt it one pull request each: MobileNav (#8590) and Selector/MultiSelector (#8591) are open; Dialog, Lightbox and ToastViewport follow their touch-presentation pull requests, and BottomSheet its sheet stack. Known exception: Drawer follows
sidewhile open; adopting the shared hold would freeze it at open, a public behavior change for a later decision, so Drawer keeps its own exit latch.No behavior change
Popover's existing tests are the oracle and pass unchanged:
Popover.test.tsx,PopoverPresentation.test.tsx(the sheet latch, rotation and reopen cases) and the Layer suite, 370 tests in all, plus the module's own tests. The real-browser check is Popover's touch-presentation specs, which this PR's CI runs because the change touches the Popover folder.Size (gzip KB, minified)
Method: a fresh
packages/coredist at the base and at this head; an entry re-exporting the component; esbuild bundle, minify, splitting, ESM, packages external. Desktop is the static-import closure; phone is all chunks.Popover gains 0.16 KB for the shared module; later adopters reuse it.
Testing
pnpm vitest run --project ui packages/core/src/Layer packages/core/src/Popover: 370 pass.[chore]changeset (internal, no behavior change).Co-authored with vjeux (the latches move from his Popover code).
Maintainer update (replayed onto main)
main; their authorship is kept.usePopoverSurfaceMotion: main's version (the sharedisCoarsePointerresolver,release()for a fine pointer) with its touch latch moved ontocreatePresentationHold;closeStartreads the hold and lets it go.layer-runtimecurrent-gaps paragraph: keeps main's newer BottomSheet and INV17 text, and states that the runtime owns the shared presentation hold, which Popover uses; the other components still build their own.presentationHold.tsheader no longer cites the record (the comment-provenance rule); the record links the file through Owning code andverified_by.vitestforpackages/core/src/Popoverandpackages/core/src/Layer: 30 files, 708 tests pass.tsc --noEmit: exit 0.check:knowledge: pass (also after the record edits). Strict lint on the changed files: clean.