Skip to content

perf(core): Lightbox's zoom and touch gestures come with the touch runtime - #11478

Draft
cixzhang wants to merge 10 commits into
perf/defer-touch-pagerfrom
perf/defer-touch-lightbox-zoom
Draft

cixzhang wants to merge 10 commits into
perf/defer-touch-pagerfrom
perf/defer-touch-lightbox-zoom

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Primary intent

Performance, stacked on #11476 (then #11466, #11463 and #11450): Lightbox stops importing its zoom stage (useZoomCore, useZoomStage), its tap and press recognizers and the animator statically. It renders them as one touch-runtime part once the shared loader has loaded the runtime. With this, no static path from the Lightbox entry reaches the animator or the gesture host. It is not a bug fix or a feature: nothing changes after the load, and there's no API change.

User or maintainer impact

  • People loading a page with a Lightbox download less JavaScript before first paint. The page-level numbers come at the end of the stack.
  • Before the runtime loads (first paint, then idle, at most 2 s), following S&D's ruling (option A):
    • a Lightbox shows each item at its fit size;
    • the zoom keys, double-click and pinch do nothing visible and announce nothing;
    • a drag does not dismiss;
    • the close button, Escape, the backdrop (a finger's tap beside the media included) and paging work as always.
  • Once the runtime loads, zoom works at once, also in a Lightbox that is already open.

Problem and solution fit

  • Before: Lightbox called useZoomCore, useZoomStage, usePressTracker and a TapGestureRecognizer directly, and built the drag-to-dismiss fades with animatorFor.
  • The runtime part: LightboxTouch calls the unchanged hooks with the same options Lightbox built before.
    • It hands the stage back through useCommittedRefInto. Lightbox calls the stage through a stable proxy that does nothing and reports "not zoomed" until the stage exists.
    • The proxy's content ref keeps the current content element, and the part gives that element to the stage when it mounts, so an open Lightbox zooms from the first key after the load.
  • Before the load: a finger's click on the backdrop takes the fine-pointer path (isClickOutsideMedia), so a tap beside the media still closes.
  • The fades read animatorFor from the runtime. They only run from the stage's drag, which exists only after the load.

Authority

architecture:react-component-runtime INV13 and spec:AST-080 DEC-5 (amended in #11450), plus S&D's ruling for this PR (option A, with two conditions: nothing visible or announced before the load, and a case proving zoom right after the load in an open Lightbox). INV13's before-load sentence and Lightbox FR6 carry the line; the gap line drops Lightbox.

Change and evidence

  • Lightbox/Lightbox.tsx, utils/touchRuntimeModules.tsx (LightboxTouch), INV13, and Lightbox FR6 plus its verification row.

Scope

Components: Lightbox

  • This PR has one primary intent.
  • Independently removable deltas were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

Red first, each failing on #11476's head:

  • utils/touchRuntime.boundary.test.ts: the Lightbox entry reaches no touch module statically.
  • Lightbox.test.tsx: "does nothing visible and announces nothing for a zoom key or a double-click before the touch runtime loads", and "zooms the moment the touch runtime loads, in a Lightbox already open".

Also:

  • LightboxZoomResize.test.tsx and useLightbox.test.tsx load the runtime in beforeAll.
  • Lightbox and the suites that render it (layer dismissal, focus trap, announce, slot presence, overlay padding) plus touchRuntime: 376 passed.
  • Core typecheck and check:knowledge pass.

Writing rubric results

  • R1 present tense: pass.
  • R2–R7: none in the record.

Owner and land path

Owner: the Astryx fix loop, lane 3. Lands after #8690 merges, in stack order (#11450, #11463, #11466, #11476, #11478, #11508, #11518, #11525, #11530, #11536, #11540, #11544), each after Specs, CodeBunny at its head and green CI; the drain merges.

…ntime

Lightbox no longer imports the zoom stage, its tap and press recognizers or the animator statically: they are a runtime part it renders once the runtime has loaded, also in a Lightbox that is already open. Until then a Lightbox shows each item at its fit size: zoom keys, double-click and pinch do nothing and announce nothing, a drag does not dismiss, and the close button, Escape, the backdrop (a finger's tap included) and paging work as always. INV13 and Lightbox FR6 state it; the gap line drops Lightbox.
@vercel

vercel Bot commented Nov 13, 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 14, 2026 8: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 13, 2026
@astracat-bot

astracat-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟡 Reviewed (for maintainers only) Nov 14, 2026, 8:48 PM UTC

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 4dec962

@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: two defects in the window before the touch runtime loads need fixing. The record changes carry an engineering owner's approval at this head, so nothing waits on a spec decision.

  • Before the runtime loads, a ctrl-wheel or trackpad pinch over a hasZoom photo reaches the browser and zooms the whole page, because no zoom stage listens yet (Lightbox.tsx:1705-1715), which contradicts Lightbox FR11 ("over the photo these replace the browser's page zoom and scroll"); state the case in FR6's before-load sentence and INV13's Lightbox clause with a fresh /approve-spec, and say "a finger's pinch" in the description.
  • The new before-load test passes on the base, because there + zooms, the double-click zooms back before the assertions, and the announcement lands a frame later (Lightbox.test.tsx:1574-1578); assert after each input, wait a frame before checking the announcement, and correct the description's red-first claim (the "zooms the moment the touch runtime loads" case passes on the base by design).

Also worth a look (non-blocking): the useZoomStage.ts header still names Lightbox.tsx as its one import site, and the before-load case loads the runtime outside act(). This change relies on the loader and the record amendments of the pull requests it is stacked on, so it lands after them.

Claims and files checked
  • Claim: Lightbox no longer imports its zoom stage, its tap and press recognizers or the animator statically. Verified (the boundary case fails on the base and passes here).
  • Claim: they mount as one runtime part once the runtime loads. Verified (Lightbox.tsx:1705-1715, touchRuntimeModules.tsx:171-228).
  • Claim: no static path from the Lightbox entry reaches the animator or the gesture host. Verified (boundary test).
  • Claim: nothing changes after the load, and no API changes. Verified (117 Lightbox cases pass with the runtime loaded; the API generator lists no row for core or the themes).
  • Claim: pages with a Lightbox download less JavaScript before first paint. Verified structurally (the zoom and gesture modules leave Lightbox's static graph); not measured.
  • Claim: before the load, items show at fit size. Verified.
  • Claim: before the load, the zoom keys and a double-click do nothing and announce nothing. True in code (Lightbox.tsx:1501-1516); the new test does not prove it (above).
  • Claim: before the load, a pinch does nothing visible. False for a ctrl-wheel or trackpad pinch, which zooms the page; true for a finger's pinch (touch-action: none on the stage).
  • Claim: before the load, a drag does not dismiss. Verified (the dismissal lives in the runtime part).
  • Claim: close, Escape, the backdrop (a finger's tap beside the media included) and paging work as always. Verified (Lightbox.tsx:1290-1293; the paging case passes).
  • Claim: once the runtime loads, zoom works at once, also in an open Lightbox. Verified (new case).
  • Claim: the part calls the unchanged hooks with the same options and hands the stage back to a no-op proxy. Verified.
  • Claim: the drag fades read the animator from the runtime. Verified (Lightbox.tsx:1323).
  • Claim: the two new Lightbox cases fail first on the pull request below. False: both pass there; the boundary case does fail there.
  • Claim: two more Lightbox suites load the runtime before their tests. Verified.
  • Claim: the Lightbox suites and the suites that render it pass, and the core typecheck and knowledge check pass. Verified (667 cases in 18 files).
  • File docs/architecture/react-component-runtime.md: clear
  • File docs/specs/components/Lightbox/Lightbox.spec.md: finding (FR11 left unqualified; the FR6 verification row cites the test above)
  • File packages/core/src/Lightbox/Lightbox.test.tsx: finding (the before-load case passes on the base)
  • File packages/core/src/Lightbox/Lightbox.tsx: finding (ctrl-wheel before the load)
  • File packages/core/src/Lightbox/LightboxZoomResize.test.tsx: clear
  • File packages/core/src/Lightbox/useLightbox.test.tsx: clear
  • File packages/core/src/utils/touchRuntime.boundary.test.ts: clear
  • File packages/core/src/utils/touchRuntimeModules.tsx: clear

Automated review (maintainer link)

| FR3 | Close, Previous, and Next button surfaces use Button's `button` target through IconButton rather than Lightbox-owned button targets. | Current source and target docs | settled |
| FR4 | The open viewer is a focus region through Core's shared focus-region module (`component:Dialog/DEC-2`): Tab from its last control moves focus to its first and Shift+Tab from its first moves focus to its last, so focus never leaves the viewer for the browser's own interface. | `component:Dialog/DEC-2` | settled; implementation gap |
| FR5 | Under a coarse primary pointer, after hydration, Lightbox presents FR6–FR10 with no opt-in. Lightbox's main interaction is a gesture, so every move in them (the zoom settle, a double tap's zoom, the page settle, the dismissal, a cancelled drag's return and the pinch close) is a spring on a named motion role read through the motion role table, never a literal, and a release starts at the gesture's velocity; the controls fade is companion motion on the pace of the main spring (`spec:AST-094` FR45). The dismissal plays Photos' measured springs, on the roles the Motion section lists (`spec:AST-094` FR4). Under reduced motion they follow AR6. | `spec:AST-094` FR4, FR13 | settled; implementation gap |
| FR6 | With `hasZoom`, on an image, a pinch zooms about the fingers and pans while it zooms; past the minimum or maximum the photo resists and eases back without overshoot. A double tap zooms to the larger of filling the viewer and 2×, about the tapped point; a second double tap returns to the fitted size. A zoomed photo pans with momentum and rubber-band edges. A pinch on the controls or the caption still zooms the page. Until the shared touch runtime has loaded (`architecture:react-component-runtime` INV13), a Lightbox shows each item at its fit size: pinch, double-tap, double-click and the zoom keys do not zoom, and announce nothing; a drag does not dismiss; the close button, Escape, the backdrop and paging work as always. Zoom works as soon as the runtime has loaded, also in a Lightbox that is already open. | `spec:AST-094` FR3, FR10 | settled; implementation gap |

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.

Before the runtime loads, nothing cancels a ctrl-wheel or trackpad pinch over the photo (no zoom stage listens yet), so the browser zooms the whole page, while FR11 says these inputs replace the browser's page zoom over the photo. Please name the case here and in INV13's Lightbox clause, for example: "a ctrl-wheel or trackpad pinch over the photo stays the browser's page zoom".

Comment on lines +1574 to +1578
fireEvent.keyDown(dialog, {key: '+'});
fireEvent.doubleClick(zoomTarget());
expect(zoomTarget()).toHaveAttribute('aria-pressed', 'false');
expect(zoomTarget().querySelector('img')?.style.scale ?? '').toBe('');
expect(document.body.textContent).not.toMatch(/zoomed in/i);

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.

On the base this case passes: + zooms (aria-pressed true), the double-click zooms back, and the announcer writes a frame later, so these assertions hold either way. Asserting after each input and waiting a frame makes it fail on the base and pass here:

fireEvent.keyDown(dialog, {key: '+'});
expect(zoomTarget()).toHaveAttribute('aria-pressed', 'false');
fireEvent.doubleClick(zoomTarget());
expect(zoomTarget()).toHaveAttribute('aria-pressed', 'false');
expect(zoomTarget().querySelector('img')?.style.scale ?? '').toBe('');
await act(() => new Promise(requestAnimationFrame));
expect(document.body.textContent).not.toMatch(/zoomed/i);

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 453b66e

@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: three defects in the window before the touch runtime loads need fixing. The record changes carry an engineering owner's approval at this head, so nothing waits on a spec decision.

  • Miss: before the touch runtime loads, a finger's tap beside a hasZoom photo or a gallery photo no longer closes the viewer: the new fallback at Lightbox.tsx:1290-1293 sends the click to isClickOutsideMedia, which returns false for every touch press (Lightbox.tsx:1205), so let it decide touch presses while the runtime is not loaded and add a before-load case that taps beside the photo.
  • Before the touch runtime loads, a ctrl-wheel or trackpad pinch over a hasZoom photo zooms the whole page, which Lightbox FR11 rules out ("over the photo these replace the browser's page zoom and scroll"), so name that case in FR6's before-load sentence and INV13's Lightbox clause and approve the head again.
  • The before-load test at Lightbox.test.tsx:1574-1578 also passes on the base, where + zooms, the double-click zooms back and the announcement lands a frame later, so assert after each input, wait a frame before checking the announcement, and correct the description's red-first claim.

Also worth a look (non-blocking): the comment at Lightbox.tsx:1280-1282 and the useZoomStage.ts header still describe the old wiring. This change relies on the loader and the record amendments of the pull requests it is stacked on, so it lands after them.

Claims and files checked
  • Claim: Lightbox no longer imports its zoom stage, its tap and press recognizers or the animator statically. Verified: the boundary case fails on the base and passes here, and the remaining imports are type-only.
  • Claim: they mount as one runtime part once the shared loader has loaded the runtime. Verified (Lightbox.tsx:1705-1715, touchRuntimeModules.tsx:193-228).
  • Claim: no static path from the Lightbox entry reaches the animator or the gesture host. Verified (boundary case).
  • Claim: nothing changes after the load, and there is no API change. Verified: the suites pass with the runtime loaded, and the API generator lists no row for core or the themes.
  • Claim: pages with a Lightbox download less JavaScript before first paint. True of the static graph; not measured.
  • Claim: before the load, items show at their fit size. Verified.
  • Claim: before the load, the zoom keys and a double-click do nothing visible and announce nothing. True in code and in a probe that asserts after each input; the new test does not prove it.
  • Claim: before the load, a pinch does nothing visible. True for a finger's pinch; false for a ctrl-wheel or trackpad pinch, which zooms the page.
  • Claim: before the load, a drag does not dismiss. Verified.
  • Claim: before the load, the close button, Escape and paging work as always. Verified.
  • Claim: before the load, the backdrop works, a finger's tap beside the media included, because the click takes the fine-pointer path. False: that path refuses touch presses, so a finger's tap beside a zoomable or gallery photo does not close.
  • Claim: once the runtime loads, zoom works at once, also in an open Lightbox. Verified: the new case passes, and fails when the part's hand-over is removed.
  • Claim: the part calls the unchanged hooks with the same options, and the proxy does nothing and reports not zoomed until then. Verified.
  • Claim: the drag fades read the animator from the runtime and run only from the stage's drag. Verified (Lightbox.tsx:1323).
  • Claim: the runtime and Lightbox records carry the before-load line, and the gap line drops Lightbox. Verified.
  • Claim: the boundary case and the two new Lightbox cases fail first on the pull request below. False for both Lightbox cases, which pass there; true for the boundary case.
  • Claim: two more Lightbox suites load the runtime before their tests. Verified.
  • Claim: the Lightbox suites, the suites that render Lightbox, the touch-runtime suites, the core typecheck and the knowledge check pass. Verified.
  • Claim: the record text is in the present tense. Verified.
  • File docs/architecture/react-component-runtime.md: clear
  • File docs/specs/components/Lightbox/Lightbox.spec.md: finding (FR11 left unqualified for the window)
  • File packages/core/src/Lightbox/Lightbox.test.tsx: finding (the before-load case passes on the base)
  • File packages/core/src/Lightbox/Lightbox.tsx: finding (finger tap beside the photo; ctrl-wheel before the load)
  • File packages/core/src/Lightbox/LightboxZoomResize.test.tsx: clear
  • File packages/core/src/Lightbox/useLightbox.test.tsx: clear
  • File packages/core/src/utils/touchRuntime.boundary.test.ts: clear
  • File packages/core/src/utils/touchRuntimeModules.tsx: clear

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 29cfdeb

@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: three defects in the window before the touch runtime loads need fixing. The record changes carry an engineering owner's approval at this head, so nothing waits on a spec decision.

  • Miss: before the touch runtime loads, a finger's tap beside a hasZoom photo or a gallery photo no longer closes the viewer, because the new guard at Lightbox.tsx:1291 sends that click to isClickOutsideMedia, which returns false for every touch press (Lightbox.tsx:1205), against FR16 and the new FR6 sentence that the backdrop works as always.
  • Before the runtime loads, a ctrl-wheel or trackpad pinch over a hasZoom photo zooms the whole page, while FR11 (left unamended) says these inputs replace the browser's page zoom over the photo, so FR6's before-load sentence and INV13's Lightbox clause need to name that case.
  • The before-load test at Lightbox.test.tsx:1574-1578 passes on #11476's head, as does "zooms the moment the touch runtime loads", so the description's red-first claim is false; asserting after each input and waiting a frame before the announcement check makes the first one fail there.

Smaller points: the comment at Lightbox.tsx:1280-1282 says the keys and the backdrop work as always before the load, and the useZoomStage.ts header still names Lightbox.tsx as its one import site.

Claims and files checked
  • Claim: Lightbox no longer imports the zoom stage, its tap and press recognizers or the animator statically: verified (the boundary case fails on the base and passes here).
  • Claim: no static path from the Lightbox entry reaches the animator or the gesture host: verified (same case).
  • Claim: nothing changes after the load and there is no API change: verified (every input checked behaves as on the base once loaded; no public API row changes).
  • Claim: pages with a Lightbox download less JavaScript before first paint: not measured; the description defers the numbers.
  • Claim: before the load each item shows at its fit size: verified (the stage proxy does nothing until the stage exists).
  • Claim: before the load the zoom keys, double-click and pinch do nothing visible and announce nothing: verified for the keys, a double-click and a finger's pinch; false for a trackpad pinch, which zooms the page.
  • Claim: before the load a drag does not dismiss: verified from code (the dismissal lives in the deferred stage).
  • Claim: before the load the close button, Escape, the backdrop (a finger's tap beside the media included) and paging work as always: false for a finger's tap beside a hasZoom or gallery photo; verified for the rest.
  • Claim: once the runtime loads, zoom works at once, also in an open Lightbox: verified.
  • Claim: LightboxTouch calls the unchanged hooks with the same options and hands the stage back through useCommittedRefInto, and Lightbox calls a no-op proxy until then: verified (touchRuntimeModules.tsx:193-228, Lightbox.tsx:1497-1515).
  • Claim: before the load a finger's click on the backdrop takes the fine-pointer path, so a tap beside the media still closes: false (Lightbox.tsx:1205).
  • Claim: the dismissal fades read the animator from the runtime and run only after the load: verified (Lightbox.tsx:1323).
  • Claim: the new tests fail first on #11476's head: verified for the boundary case; false for both Lightbox.test.tsx cases.
  • Claim: LightboxZoomResize.test.tsx and useLightbox.test.tsx load the runtime in beforeAll: verified.
  • Claim: the Lightbox and touch-runtime suites, the core typecheck and the knowledge check pass: verified.
  • File docs/architecture/react-component-runtime.md: finding (the ctrl-wheel case is unnamed in INV13's Lightbox clause).
  • File docs/specs/components/Lightbox/Lightbox.spec.md: finding (the ctrl-wheel case is unnamed in FR6; the verification row cites a test that passes on the base).
  • File packages/core/src/Lightbox/Lightbox.tsx: finding (a finger's tap beside the photo before the load).
  • File packages/core/src/Lightbox/Lightbox.test.tsx: finding (the before-load test passes on the base).
  • File packages/core/src/Lightbox/LightboxZoomResize.test.tsx: clear.
  • File packages/core/src/Lightbox/useLightbox.test.tsx: clear.
  • File packages/core/src/utils/touchRuntime.boundary.test.ts: clear.
  • File packages/core/src/utils/touchRuntimeModules.tsx: clear.

Automated review (maintainer link)

Comment thread packages/core/src/Lightbox/Lightbox.tsx Resolved
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 96d5626

@cixzhang

Copy link
Copy Markdown
Contributor Author

Decision: D-20261113-274

Records the owner's answer that the touch runtime loads once per page after first paint, never on demand, at 96d5626. Until it loads, items show at fit size and zoom does nothing, while close, Escape, the backdrop and paging work; zoom works as soon as it loads. It waives nothing.

@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: three defects in the window before the touch runtime loads need fixing. The record changes carry an engineering owner's approval for this head, so no spec decision is pending.

  • Miss: before the runtime loads, a finger's tap beside a hasZoom or gallery photo leaves the viewer open, because the click now falls to isClickOutsideMedia, which refuses every touch press (Lightbox.tsx:1291 with :1205), against ORD3 and the approved FR6 text that the backdrop works as always.
  • Before the runtime loads, a ctrl-wheel or trackpad pinch over the photo zooms the whole page, which FR11 says these inputs replace, so FR6's before-load sentence and INV13's Lightbox clause need to name that case for an engineering owner to approve.
  • The before-load case at Lightbox.test.tsx:1574-1578 passes on the base (the double-click zooms back before the first assertion, and the announcer writes a frame later), so it does not prove the window the FR6 verification row cites it for, and the description's red-first claim for it is false.

The earlier inline comments on those lines still apply and suggest each fix. The boundary test, the stage proxy and the after-load path otherwise check out.

Claims and files checked
  • Claim: no static path from the Lightbox entry reaches the animator or the gesture host. Verified: the boundary case fails on the base and passes here.
  • Claim: nothing changes after the load, and no API changes. Verified: after the load the probe matches the base, and the API surface lists no change.
  • Claim: before the load each item shows at its fit size and a drag does not dismiss. Verified: the stage and its dismiss pan mount only with the runtime part.
  • Claim: before the load the zoom keys, double-click and pinch do nothing visible and announce nothing. False for a ctrl-wheel or trackpad pinch, which zooms the page.
  • Claim: before the load the close button, Escape, the backdrop (a finger's tap beside the media included) and paging work. False for a finger's tap beside a zoomable or gallery photo.
  • Claim: zoom works as soon as the runtime loads, also in an open Lightbox. Verified by the new after-load case.
  • Claim: the runtime part calls the unchanged zoom hooks with the same options, and the fades read the animator from the runtime. Verified from source.
  • Claim: the new cases fail first on the lower pull request's head. True for the boundary case; false for both Lightbox cases, which pass there.
  • Claim: two suites load the runtime before their tests, and the Lightbox suites, typecheck and knowledge check pass. Verified.
  • docs/architecture/react-component-runtime.md: the Lightbox clause omits the ctrl-wheel case (finding 2).
  • docs/specs/components/Lightbox/Lightbox.spec.md: FR6 omits the ctrl-wheel case (finding 2); its verification row cites the case in finding 3.
  • packages/core/src/Lightbox/Lightbox.tsx: finding 1; a comment overstates what works before the load (non-blocking).
  • packages/core/src/Lightbox/Lightbox.test.tsx: finding 3.
  • packages/core/src/utils/touchRuntimeModules.tsx: clear.
  • packages/core/src/Lightbox/LightboxZoomResize.test.tsx: clear.
  • packages/core/src/Lightbox/useLightbox.test.tsx: clear.
  • packages/core/src/utils/touchRuntime.boundary.test.ts: clear.

Automated review (maintainer link)

# Conflicts:
#	docs/specs/components/Lightbox/Lightbox.spec.md
#	packages/core/src/Lightbox/Lightbox.tsx

@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.

Approval waits on an engineering owner's decision, and three defects in the window before the touch runtime loads need fixing.

The record changes this pull request depends on (Lightbox FR6's before-load sentence and its verification row, and INV13's Lightbox clause) have no engineering-owner approval at this head: the earlier approval named the previous head, and the merge of the base branch since then is a new commit. An engineering owner records the decision by commenting /approve-spec followed by the full head SHA; the author may do so if they are an engineering owner.

Blocking findings:

  • Before the runtime loads, a finger's tap beside the photo no longer closes any Lightbox (single or gallery, with or without zoom), because the guard at Lightbox.tsx:1239-1241 hands the click to isClickOutsideMedia, which refuses every touch press at Lightbox.tsx:1169; this contradicts ORD3 and FR6's own "the backdrop works as always", so let that helper decide a touch press while the runtime is absent and add before-load tap cases for a single photo, a zoomable photo and a gallery.
  • Before the runtime loads, a ctrl-wheel or trackpad pinch over the photo zooms the whole page, which FR11 says these inputs replace over the photo, so name that case in FR6's before-load sentence and INV13's Lightbox clause for the owner to approve.
  • The before-load case at Lightbox.test.tsx:1575-1579 passes on the base (the + zoom and the double-click cancel out, and the announcer writes a frame later), so it does not prove the window the FR6 verification row cites it for; assert after each input and wait a frame before checking the announcement.

A non-blocking note: the JSDoc at touchRuntimeModules.tsx:179 still calls the backdrop tap a gallery's, but it now applies to every Lightbox without zoom.

Claims and files checked

Claims:

  • No static path from the Lightbox entry reaches the animator or the gesture host: verified (the boundary case fails on the base with two chains and passes here).
  • No API change: verified (no public API rows for Core or the themes).
  • Before the load, items show at fit size, and the zoom keys and a double-click do nothing and announce nothing: verified on this head, but the test meant to prove it also passes on the base.
  • Before the load, a pinch does nothing visible: false for a trackpad pinch, which zooms the page.
  • Before the load, a drag does not dismiss: verified from the source (the drag lives in the deferred stage).
  • Before the load, the backdrop and a finger's tap beside the media close the viewer: false (Lightbox.tsx:1169).
  • Once the runtime loads, zoom works at once in an open Lightbox: verified (Lightbox.test.tsx:1585).
  • The runtime part calls the unchanged hooks with the same options and hands the stage back through the shared committed-ref hook: verified.
  • The drag fades read the animator from the runtime: verified (Lightbox.tsx:1264).
  • Each new test fails on the base: true for the boundary case, false for both Lightbox cases.
  • The zoom-resize and hook suites load the runtime first: verified.
  • The Lightbox suites, core typecheck and the knowledge check pass: the changed suites (154 tests), typecheck and the knowledge check pass here; the full 376-test run was not repeated.
  • The records are in the present tense: verified.

Files:

  • docs/architecture/react-component-runtime.md: awaits owner approval; does not name the ctrl-wheel case.
  • docs/specs/components/Lightbox/Lightbox.spec.md: awaits owner approval; does not name the ctrl-wheel case; its verification row cites a test that passes on the base.
  • packages/core/src/Lightbox/Lightbox.tsx: a finger's tap beside the photo does not close before the load.
  • packages/core/src/utils/touchRuntimeModules.tsx: clear apart from the JSDoc note.
  • packages/core/src/Lightbox/Lightbox.test.tsx: the before-load case passes on the base.
  • packages/core/src/Lightbox/LightboxZoomResize.test.tsx: clear.
  • packages/core/src/Lightbox/useLightbox.test.tsx: clear.
  • packages/core/src/utils/touchRuntime.boundary.test.ts: clear.

Automated review (maintainer link)

}
const isMediaClose =
pointerTypeRef.current !== 'touch' && isClickOutsideMedia(e);
(pointerTypeRef.current !== 'touch' || touchRuntime == 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.

Before the runtime loads, this guard sends a finger's click to isClickOutsideMedia, but that helper returns false for every touch press (pointerTypeRef.current === 'touch' at line 1169). So until the runtime loads, a tap beside the photo closes no Lightbox: a single photo or a gallery, with or without hasZoom (the base closes in each case). One way: let isClickOutsideMedia decide a touch press while touchRuntime is null, and add before-load cases that tap beside a single photo, a hasZoom photo and a gallery photo.

/** The current item's content, which the stage zooms. */
readonly contentElementRef: RefObject<HTMLElement | null>;
readonly captionToggleRef: RefObject<HTMLElement | null>;
/** A finger's tap on a gallery's stage without zoom. */

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 tap is enabled for every Lightbox without zoom (isOpen && !isZoomTarget in Lightbox.tsx), single photos included, so "a gallery's stage" no longer matches. Suggest: /** A finger's tap on the stage when the item has no zoom. */

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 876d5da

@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: an engineering owner has approved the FR6 and INV13 record text at this head, but three defects in the window before the touch runtime loads still need fixing.

  • Before the runtime loads, a finger's tap beside the photo closes no Lightbox (a single photo, a hasZoom photo or a gallery page), because the new guard at Lightbox.tsx:1239-1241 hands touch clicks to isClickOutsideMedia, which still returns false for every touch press (Lightbox.tsx:1169), against ORD3, FR16 and FR6's own "the backdrop … work as always".
  • Before the runtime loads, nothing cancels a ctrl-wheel or trackpad pinch over a hasZoom photo, so the browser zooms the whole page against FR11 ("over the photo these replace the browser's page zoom"); cancel it before the load, or name the case in FR6 and INV13 and get a new approval.
  • The before-load case at Lightbox.test.tsx:1563-1583 passes on the base, because + zooms, the double-click zooms back and the announcement lands a frame later, so the red-first claim is false; assert after each input and check the announcement after one frame.

The inline comments already on these lines carry the suggested fixes. After the load Lightbox behaves as on the base, and no public API changes.

Claims and files checked
  • Claim: no static path from the Lightbox entry reaches the touch modules. Verified: the boundary case fails on the base and passes on the head.
  • Claim: before the load, items stay at fit size and the zoom keys, double-click and pinch do nothing and announce nothing. Verified in Chromium with the runtime held back, and by an assert-after-each-input variant of the test.
  • Claim: before the load, a drag does not dismiss. Verified from the code: the drag to dismiss exists only in the runtime part.
  • Claim: before the load, the close button, Escape and paging work as always. Verified by the head's suites.
  • Claim: before the load, the backdrop works, a finger's tap beside the media included. False (first finding).
  • Claim: once the runtime loads, zoom works at once, also in an open Lightbox. Verified (Lightbox.test.tsx:1585-1600).
  • Claim: nothing changes after the load, and there is no API change. Verified by after-load probes and an API comparison with no rows.
  • Claim: the boundary case is red first. Verified. Claim: both new Lightbox cases are red first. False: both pass on the base (third finding).
  • Claim: the zoom-resize and useLightbox suites load the runtime in beforeAll. Verified in the diff.
  • Claim: Lightbox and the suites that render it pass. Verified for 13 files and 373 tests; the stated 376 was not matched to a file list.
  • Claim: Core typecheck and the knowledge check pass. Verified.
  • File packages/core/src/Lightbox/Lightbox.tsx: first finding.
  • File packages/core/src/utils/touchRuntimeModules.tsx: second finding (no wheel handler before the load); the JSDoc at line 179 says "a gallery's stage" but the tap serves every Lightbox without zoom (non-blocking).
  • File packages/core/src/Lightbox/Lightbox.test.tsx: third finding.
  • File packages/core/src/Lightbox/LightboxZoomResize.test.tsx: clear.
  • File packages/core/src/Lightbox/useLightbox.test.tsx: clear.
  • File packages/core/src/utils/touchRuntime.boundary.test.ts: clear.
  • File docs/specs/components/Lightbox/Lightbox.spec.md: approved at this head; FR11 is left unamended (second finding).
  • File docs/architecture/react-component-runtime.md: approved at this head; clear.

Automated review (maintainer link)

# Conflicts:
#	docs/architecture/react-component-runtime.md

@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.

Approval waits on an engineering owner's decision, and three defects in the window before the touch runtime loads need fixing.

Lightbox FR6's before-load sentence and verification row, and the runtime architecture's INV13 Lightbox clause with Lightbox dropped from its gap list, are new record text. The last approval named an earlier head and this head is a new merge of the base branch, so an engineering owner records the decision again by commenting /approve-spec with the full head SHA on this pull request; the author may do so if they are an engineering owner. Fixing the defects below first avoids a second approval.

  • Before the runtime loads, a finger's tap beside the photo closes no Lightbox, single photo or gallery, with or without hasZoom, because isClickOutsideMedia returns false for every touch press (Lightbox.tsx lines 1239-1241 with 1169), against ORD3, FR16 and the proposed FR6's "the backdrop ... work as always".
  • Before the runtime loads, a ctrl-wheel or trackpad pinch over a hasZoom photo zooms the whole page because no zoom stage listens yet, against FR11, so either cancel it before the load or name the case in FR6 and INV13 for the owner's approval.
  • The new test "does nothing visible and announces nothing for a zoom key or a double-click before the touch runtime loads" passes on the base, because + zooms and the double-click zooms back before the final assertions, so assert after each input and check the announcement after one frame.
Claims and files checked

Review mode: full; reason: spec-record

  • Claim: no static path from the Lightbox entry reaches the touch modules: verified (the boundary case fails on the base and passes here).
  • Claim: before the load, the zoom keys, double-click and pinch do nothing visible and announce nothing: verified in code and by a stricter test; the pull request's own test does not prove it.
  • Claim: before the load, the close button, Escape, paging and the backdrop, a finger's tap beside the media included, work as always: false for the finger's tap (first finding).
  • Claim: a drag does not dismiss before the load: verified (the drag exists only in the zoom stage).
  • Claim: zoom works as soon as the runtime loads, also in an open Lightbox: verified (the new test passes here).
  • Claim: nothing changes after the load and there is no API change: verified (after-load checks match the base; the generated API delta has no rows).
  • Claim: each new test fails first on the base: false for the before-load Lightbox test (third finding).
  • Claim: the zoom-resize and hook suites load the runtime before they run: verified.
  • Claim: the Lightbox suites, core typecheck and the knowledge check pass: verified for the Lightbox and touch-runtime suites (201 tests), core typecheck and the knowledge check; the full 376-test tally was not rerun.
  • packages/core/src/Lightbox/Lightbox.tsx: first finding; the comment at lines 1229-1231 says the backdrop works as always.
  • packages/core/src/utils/touchRuntimeModules.tsx: second finding; the comment at line 179 names only a gallery's stage, but the tap covers every Lightbox without zoom.
  • packages/core/src/Lightbox/Lightbox.test.tsx: third finding.
  • packages/core/src/Lightbox/LightboxZoomResize.test.tsx: clear.
  • packages/core/src/Lightbox/useLightbox.test.tsx: clear.
  • packages/core/src/utils/touchRuntime.boundary.test.ts: clear.
  • docs/specs/components/Lightbox/Lightbox.spec.md: awaits the owner's approval; matches the code apart from the first two findings.
  • docs/architecture/react-component-runtime.md: awaits the owner's approval; matches the code apart from the first two findings.

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec b4e6db6

@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: an engineering owner has approved the FR6 and INV13 record text at this head, but three defects in the window before the touch runtime loads still need fixing.

The fixing commit is a new head, so the record approval has to be given again there.

  • Before the runtime loads, a finger's tap beside the photo closes no Lightbox, single photo or gallery, with or without hasZoom, because isClickOutsideMedia returns false for every touch press (Lightbox.tsx lines 1239-1241 with 1169), against ORD3, FR16 and the approved FR6 and INV13 text, which say the backdrop works as always.
  • Before the runtime loads, a ctrl-wheel or trackpad pinch over a hasZoom photo zooms the whole page because no zoom stage listens yet, against FR11, so either cancel it before the load or name the case in FR6 and INV13 for the owner's approval.
  • The new test "does nothing visible and announces nothing for a zoom key or a double-click before the touch runtime loads" passes on the base, because + zooms and the double-click zooms back before the final assertions run, so assert after each input and check the announcement after one frame.
Claims and files checked

Review mode: same-head; reason: none

  • Claim: no static path from the Lightbox entry reaches the animator or the gesture host: verified (the boundary case fails on the base and passes here; a static walk of the import graph agrees).
  • Claim: pages with a Lightbox download less JavaScript before first paint: verified structurally (the entry reaches no touch module); the byte numbers are deferred to the end of the stack.
  • Claim: before the load, each item shows at its fit size and the zoom keys, double-click and pinch do nothing visible and announce nothing: verified in code and by a stricter test; the pull request's own test does not prove it.
  • Claim: before the load, a drag does not dismiss: verified (the drag exists only in the zoom stage, which mounts with the runtime).
  • Claim: before the load, the close button, Escape, paging and the backdrop, a finger's tap beside the media included, work as always: false for the finger's tap (first finding).
  • Claim: before the load, a finger's click on the backdrop takes the fine-pointer path, so a tap beside the media still closes: false, because that path rejects every touch press (first finding).
  • Claim: once the runtime loads, zoom works at once, also in an open Lightbox: verified (the new test passes here).
  • Claim: the runtime part calls the unchanged zoom hooks with the same options, and the stage proxy does nothing and reports not zoomed until the stage exists: verified in code.
  • Claim: the drag-to-dismiss fades read the animator from the runtime and run only from the stage's drag: verified in code.
  • Claim: nothing changes after the load and there is no API change: verified (after-load checks match the base; the generated API delta has no rows).
  • Claim: each new test fails first on the base: false for the before-load Lightbox test (third finding); true for the boundary case.
  • Claim: the zoom-resize and hook suites load the runtime before they run: verified.
  • Claim: the Lightbox suites, core typecheck and the knowledge check pass: verified for the Lightbox and touch-runtime suites, core typecheck and the knowledge check; the full 376-test tally was not rerun.
  • Claim: the record text is in the present tense: verified.
  • packages/core/src/Lightbox/Lightbox.tsx: first finding; the comment at lines 1229-1231 says the backdrop works as always.
  • packages/core/src/utils/touchRuntimeModules.tsx: second finding; the comment at line 179 names only a gallery's stage, but the tap covers every Lightbox without zoom.
  • packages/core/src/Lightbox/Lightbox.test.tsx: third finding.
  • packages/core/src/Lightbox/LightboxZoomResize.test.tsx: clear.
  • packages/core/src/Lightbox/useLightbox.test.tsx: clear.
  • packages/core/src/utils/touchRuntime.boundary.test.ts: clear.
  • docs/specs/components/Lightbox/Lightbox.spec.md: owner-approved at this head; the head breaks its approved FR6 backdrop sentence and the unamended FR11 (first two findings).
  • docs/architecture/react-component-runtime.md: owner-approved at this head; the head breaks its approved backdrop sentence (first finding) and otherwise matches the code.

Automated review (maintainer link)

This branch was successfully deployed

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

Labels

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.

1 participant