Repository navigation
fix(Lightbox): a mouse click beside the shown photo closes the viewer - #11354
Conversation
A single photo's caption had no backing, so its white text over the backdrop measured 4.00:1 over a white page, under FR17's 4.5:1. It now sits on the backing that a gallery's caption band uses, reaching below its last line as far as above its first: 17.22:1 over a white page. The record drops the gap.
A single photo laid out its caption on its own: under the photo, centred with it, on a plate as wide as its text. Its caption now shows as a gallery page's does. The photo is the one page of the viewer's track, and its caption sits in the band at the bottom of the viewer, on the same backing, two lines tall with "more" for a longer one. A photo with no caption has no band. Only paging stays a gallery's: a single photo shows no Previous, Next or counter and has no pager, and a drag past a zoomed photo's edge springs back. A zoomable photo's box now takes the stage's cursor, not the reset's button cursor, so a gallery shows the zoom-in cursor over its fitted photo too. The zoom core's fit callback, which only the single photo's caption used, goes.
Each page of a Lightbox gallery laid out its own photo and caption, so a neighbour with a longer caption arrived with a smaller photo. Every page now has a caption band two caption lines tall under its photo, whatever the caption, so the photo area is the same on every page and paging never resizes it. A page with no caption keeps the band's space, so its photo sits where every other page's does, but it shows no backing there. A longer caption shows two lines, and its second line ends in a "more" button, so the caption keeps the band's whole width. The toggle is one line tall, so its fill stays on that line. The button opens the whole caption over the bottom of the photo, on the scrim the controls use, and its "less" closes it. An open caption too long for its panel scrolls, and it keeps the toggle's width clear at the end of every line. Paging closes it too. The whole caption is always the viewer's accessible description, clamped or open. The viewer lays out no hidden copies of other captions. Each caption renders the same elements in every state: without a toggle, the toggle's place in its last line has no size. The viewer renders inside MediaTheme, dark, so its controls, caption and counter take the theme's dark surface tokens and its rules for them, with no Lightbox-owned colors beyond the controls' and the caption's backing. The caption is body Text, both of its lines start at one edge, and "more" and "less" are a ghost Button. The band clears the screen's bottom edge and its safe area. Focus the viewer moves follows the last input, so a tap that opens it paints no ring. The caption sits on its own backing, the controls' backing colour at 90 %, so it keeps 4.5:1 over any photo or backdrop behind it. With zoom, the controls' icons and the Counter's text keep the on-dark colour, whatever a theme does to buttons or Text. An open caption is the clamped caption itself, unclamped over the photo's bottom, so the caption renders once. In a gallery the keyboard's zoom button is the current page's photo box, so the caption band and its button sit outside it, and Enter or Space on "more" toggles the caption. Paging from a focused "more", "less" or photo moves focus to the new page's photo, or to Close without zoom, so the arrow keys keep paging. "Less" keeps its focus. It folds in the follow-ups that sat on it as separate commits: a caption that grows past two lines gets "more"; the GalleryKeepsIndex story keeps its description; the caption is measured after layout, not in the commit; the caption toggle takes its width from its delivery; and a caption delivery reads first and commits once.
The translator notes for "more" and "less" described only a gallery's caption, and the record's "Captioned media" state named the old centred group. A single photo now shows its caption in the same band, so both say so. FR1b's exception now names the touch pager, which takes a gallery's edge drag.
Lightbox is a full-screen viewer, not an anchor-mode layer. Its caption band keeps the device's bottom safe-area inset under the caption, as Drawer's and BottomSheet's panels keep theirs. So the check that only the layer module defines an anchored layer's gutter lists it with the other surfaces that read the device's insets themselves.
The spec owners set FR1b's scope: a single captioned item, a photo or a video, shows its caption exactly as a gallery caption does, in the band. FR1b's first sentence and the "Captioned media" state now say so. The code already shows a single video's caption in the band.
Main's Lightbox record now has FR17, an index past either end, and FR18, a paged-away video. This branch's media-surface requirement, also numbered FR17, becomes FR19, with its verification row and its Current-state entry.
The caption band now carries main's FR17 and FR18, and its media-surface requirement is FR19. This branch's verification row for it follows as FR19, and the single photo's caption-contrast gap stays removed: this branch fixes it.
The owner's message reads differently from the sentence FR1b quoted. FR1b now keeps only her exact fragment, "they really should be consistent", and says the rest in plain prose.
Main now judges the double-tap zoom's busy proof on the photo's top edge instead of its height, which this branch's last run failed on.
The caption band now carries main's busy-proof fix for the double-tap zoom; this branch changes nothing there.
Main's drag to close and this branch both change Lightbox.tsx, and the merge keeps both. The controls sit in the drag's click-through layers inside the media surface, and each takes its own clicks. A page's photo box keeps its row in the band's grid and takes the dismissal's overflow and stacking. The every-pointer spec keeps a new case from each side. Main's new fine-pointer case counts the media surface too.
Main's drag to close fades the controls and the caption with its travel. In a gallery the caption's backing is its band, which stayed opaque over the fading backdrop. The band now fades in the caption's place, once.
The caption's toggle was a ghost Button with a size of its own. It is now Link's button form: a native button in the caption's own font and line height, underlined, at the end of the caption's last line. It keeps aria-expanded and aria-controls, and the shared hit area still grows its tap toward 44 px under a finger. Lightbox's record, docs and changeset say so.
The caption band now carries main's drag to close, and shows "more" and "less" as an inline link. On this branch every item is a page of the track, a single photo too. So the drag to close moves each page's photo box, and the track takes its touches. After a cancelled drag, the stage's own tap beside the photo still closes the viewer. The zoom core drops its fit callback, which only placed the old single caption. Main's cases that read that caption read its band instead.
The caption's "more" and "less" grew their touch target through their own copy of the shared hit area: a watch and a band of their own. They now use Core's touch hit area and its layer, as other controls do, with a growth that never reaches up into the caption's line above. Lightbox's record marks FR19's single-photo gap, and the contrast case adds the black photo its verification row names.
The caption band's "more" and "less" now take their touch target from Core's touch hit area, growing toward 44 px down and to each side but never up. A single photo's caption uses the same toggle, so it gets the fix too. FR19 stays settled here, since this branch closes the single photo's contrast gap the caption band's record lists.
Main now plays the drag to close at the theme's tempo, and Lightbox's record says so in FR5 and its Motion section. The merge keeps main's FR5 row, Motion paragraph and verification row, and this branch's FR1 and FR19 rows. The dismissal spec keeps both sides' new cases.
The caption band now carries main's tempo for the drag to close, and its record's FR5 row and Motion section. Every item here is a page of the track, so a single photo's drag to close plays at that tempo too.
Main now measures a new text on the shared observer's first notification. The merge keeps that in useTruncation's observing path, which this branch moved into the measurement both hooks share. The caption's held measurement observes nothing, as before.
The caption band now carries main's first truncation measurement on the shared observer's first notification. A single photo's caption uses the same held measurement as a gallery's, so nothing else changes here.
Main now opens a NaN or fractional index on the nearest item, and Lightbox's record says so in FR17. The merge keeps main's FR17 rows and this branch's FR1 and FR19 rows. The index code merges as it is.
The caption band now carries main's nearest-item index for a NaN or fractional index, and its record's FR17 rows. FR19 stays settled here.
Main's Lightbox busy proofs now block as their motion starts, and the busy page-settle test decodes each frame once and fails by name when too slow. The merge keeps this branch's traceRendering import beside main's new trackMarkers one.
The caption band now carries main's busy proof fixes for Lightbox, including the page-settle pool that decodes each frame once. Nothing else changes here.
The caption toggle used the link's accent colour. A theme build whose media surface keeps a dark accent drew it near-black on the dark band, so "more" could not be seen. The toggle now inherits the caption's colour, and the underline sets it apart.
The caption band's "more" and "less" now take the caption's colour, so a theme build whose media surface keeps a dark accent cannot hide them. This branch's caption markup differs there, so the merge applies the same one-line change to its toggle by hand.
Main's viewer is now heard by screen readers, and 0 resets the zoom. Two hunks join by hand: the component's summary takes main's "images and videos" beside this branch's resize helper, and the keyboard spec keeps main's new zoom case before this branch's caption cases.
The caption band now carries main's screen reader and zoom reset changes for Lightbox. Nothing else changes here.
Lightbox kept its own copy of the shared ResizeObserver's skip of the registration call, and the copy differed from useTruncation's. For an element another subscriber already observed, it waited for a resize that might never come. One export, observeResizeAfterLayout, now holds the skip and the microtask measure, and both call it.
A click closed the viewer only outside a band as wide as the photo's natural width, or as its caption where the caption was wider. Beside a photo scaled down to fit, or narrower than its caption, the dark space in that band kept it open. The band is now the photo's laid-out width, so the record's implementation gap line goes.
|
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 |
|---|---|---|---|
| lab/Comments | 366.9 kB (−44 B) · 2.5 kB CSS (0) | — | — · — · — |
| Lightbox · Storybook | 144.7 kB (−57 B) · 11.5 kB CSS (0) | 4,665 (+42) | ✓ · ✓ · ✓ |
| lab/CommentThread | 360.1 kB (−68 B) · 2.4 kB CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 7.51 MB packed (−128 B); no new dependencies.
Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
|
/approve-spec 3616651 |
There was a problem hiding this comment.
Changes requested: the click fix itself is small and its record change is approved at this head, but three points need work before this can merge.
- Desktop behavior change needs an owner decision: a mouse click on the dark space beside the photo now closes the viewer where main kept it open (
packages/core/src/Lightbox/Lightbox.tsx:1201); gate it to touch input, or cite the owner decision that covers it. UseTruncationOptions.isExpanded(useTruncation) is outside this pull request's scope (Lightbox): name it in the scope and get an owner decision, or split it into its own pull request.- The description's "Public and internal API delta: None" is false for this diff against main, because this body's
Stack:line differs from the one in #9810 and #10284; put the identical lineStack: #9810 → #10284 → #11354in all three bodies so each pull request is reviewed on its own increment, which also takesisExpandedout of this one.
CI has not run on this draft yet, so none of the new browser tests have run at this head. Two caption reads follow a flushSync commit and force a layout (Lightbox.tsx:1015-1020, :2026-2030); reading before the write would avoid them, but they are not blocking.
Claims and files checked
- Verified: a click beside a scaled-down photo, or beside a photo narrower than its caption, now closes the viewer, and before it stayed open within the photo's natural width or a wider caption (
Lightbox.tsx:1201; the base's natural-width test). - Verified: the caption band and the caption's own box still keep the viewer open (
Lightbox.tsx:1226-1237). - Verified: a gallery caption sits in a two-line band on a backing, a page with no caption keeps the band's space without the backing, and the band clears the bottom safe area (
Lightbox.tsx:353-379). - Verified: a longer caption ends in an inline "more" link in Link's button form that opens it over the photo, and the full caption is the viewer's accessible description (
Lightbox.tsx:2007-2043,:1783-1785). - Verified: the viewer renders under the dark media theme with body Text for the caption and the counter (
Lightbox.tsx:1813,:2070-2082). - Verified: a tap that opens the viewer paints no focus ring, and paging from a focused "more" or "less" keeps focus in the viewer (
Lightbox.tsx:853-860,:1486-1500). - Verified: a single photo's caption shows in the same band with "more", and a single photo with no caption shows no band (
Lightbox.tsx:1758-1761). - Verified:
useTruncationtakesisExpandedand keeps its clamped answer while it is true (useTruncation.ts:137-144). - Verified: this pull request's own increment is +144/−83 and removes the record's gap line.
- Asserted by tests only: the caption keeps 4.5:1 on its backing in every theme.
- False: "Public and internal API delta: None" for the diff against main (
useTruncation.ts:26-30). - Not verified: the red-first runs, gate results, test counts and screenshot comparison in the description (CI skipped the draft).
- Findings:
Lightbox.tsx(desktop click; two non-blocking forced layouts),useTruncation.ts(scope). - Clear: the four changesets,
Lightbox.stories.tsx,react-component-runtime.md, the layer-text-boundary spec,Lightbox.spec.md,Text.spec.md,en.json,layerViewportInset.test.ts,Lightbox.doc.mjs,Lightbox.test.tsx,LightboxFinePointer.a11y.browser.spec.ts,LightboxKeyboard.a11y.browser.spec.ts,LightboxViewport.a11y.browser.spec.ts,LightboxZoomResize.test.tsx,LightboxDismiss,LightboxEveryPointer,LightboxPaging,LightboxPagingModes,LightboxSingleCaption,LightboxZoomandLightboxZoomModesinteraction specs,useZoomCore.ts,useZoomStage.ts,useTruncation.doc.mjs,useTruncation.test.tsx,sharedResizeObserver.ts,sharedResizeObserver.test.ts.
|
/approve-spec b0cc21e |
There was a problem hiding this comment.
Approved pending CI: CI has not finished on this head yet.
A mouse or pen click on the dark space beside a Lightbox photo now closes the viewer, also beside a photo scaled down to fit and beside one narrower than its caption, which brings the viewer in line with the Lightbox record's desktop click rule and closes the gap the record listed. In a browser, clicks 4 px and 20 px beside a scaled-down photo, and a click beside a narrow photo within its caption's width, stayed open before this change and close with it, while clicks on the photo and on the caption band still keep the viewer open. Nothing else is needed from you.
Claims and files checked
Claims:
- A mouse click on the dark space beside a photo now closes the viewer, including beside a scaled-down photo and beside one narrower than its caption: verified (browser clicks before and after;
Lightbox.tsx:1179). - Before, a click closed only outside a band as wide as the photo's natural width, or a wider caption: verified (the removed width computation).
- A 1200 px photo shows 1110 px wide in a 1280 × 800 window, leaving a strip inside that band on each side: verified (measured).
- The record's desktop click sentence states the expected behaviour, came from an earlier owner-approved pull request, and this change removes the gap the record listed: verified (record history and the record at this head).
- The spec owner approved the removal of the gap: verified (an owner approval names this head).
- The fix takes the photo's laid-out width and drops the natural width, the caption's width and the viewer cap: verified (diff).
- The caption band and the caption's box still keep the viewer open: verified (unchanged code; a click on the band stays open before and after).
- At 1280 × 800, clicks 4 px and 20 px beside the photo stay open before and close after: verified (browser clicks on a story with the same photo size).
- A click on the photo, the caption band or the counter leaves the viewer open: verified for the photo and the band by browser clicks, and for the counter by its unchanged test, which was not run here.
- Each regression test fails before the fix: verified for the two unit cases (they fail against the previous code); for the browser cases, the same clicks stay open before the change in a browser, and the cases pass in CI on this head.
- The test list (one new browser case, six flipped cases, two extended cursor cases, two unit cases): verified by reading.
- Core typecheck, strict lint on the changed files, and the knowledge and changeset checks pass: verified (re-run); the Lightbox unit file passes 117 of 117.
- The Lightbox interaction specs pass 154 with 4 skipped in Chromium: verified (CI on this head); the browser specs also pass in WebKit in CI, which runs a different set, so the WebKit and accessibility counts are not comparable; the other unit suite counts and the screenshot comparison were not re-run.
- A desktop device take at this head is pending: stated as pending.
- The line counts (+144/−83; source +3/−9, tests +134/−73, record and changeset +7/−1): verified.
- No public API delta: verified (a generated API surface comparison shows no change).
- The merge of the main branch keeps the main branch's record sentence and deletes the gap line: verified.
- Changeset: a click on the dark space beside a photo now closes the viewer, where it stayed open within the natural width or a wider caption's width: verified.
Files:
.changeset/lightbox-click-beside-scaled-photo.md: cleardocs/specs/components/Lightbox/Lightbox.spec.md: clearpackages/core/src/Lightbox/Lightbox.tsx: clearpackages/core/src/Lightbox/Lightbox.test.tsx: clearpackages/core/src/Lightbox/LightboxFinePointer.a11y.browser.spec.ts: clearpackages/core/src/Lightbox/__tests__/LightboxPagingModes.interaction.browser.spec.ts: clearpackages/core/src/Lightbox/__tests__/LightboxZoomModes.interaction.browser.spec.ts: clear
A mouse click on the dark space beside a Lightbox photo now closes the viewer. That includes a photo scaled down to fit and one narrower than its caption. Fixes #11341.
User impact
On a desktop, a photo larger than the window shows scaled down to fit. A click on the dark space beside it kept the viewer open. So did a click beside a photo narrower than its caption, within the caption's width. The same click beside other photos closed it. Now all close.
Problem and solution fit
Expected behavior and authority
A mouse click beside the shown photo, outside the photo and the caption band, closes the viewer, as Lightbox FR11's desktop backdrop sentence states; this removes the implementation gap the record listed.
That sentence comes from #9810, which the spec owner approved (
/approve-spec). The spec owner also approved this pull request's removal of the gap (/approve-spec).Smallest restoration
isClickOutsideMediatakes the photo'soffsetWidthas its width. ItsnaturalWidth, the caption's width and the viewer-width cap go.Evidence
Scope
Components: Lightbox
Testing
tscis clean, strict ESLint has no warnings on the changed files, andpnpm check:knowledgeandcheck:changesetspass. The Lightbox, Text, touch hit area, observer and motion unit files pass 1,294/1,294. The tests that read the changed record pass 38 inuiand 905 innode. In CI's profile (a 4-CPU container, 1 worker), the Lightbox interaction specs pass 154 (4 skips) in Chromium and 146 (12 skips) in WebKit. The Lightbox and Text a11y specs pass 85 in Chromium and 70 (2 skips) in WebKit. At 3616651, Chromium screenshots of 45 states matched 7282678's byte for byte.Lines (d6cadde..b0cc21e): +144/−83 in all: source +3/−9, tests +134/−73, and the record and the changeset +7/−1.
Public and internal API delta
None. No export, prop, type, default, hook, module or data attribute changes, and no new source file.
History