Skip to content

fix(Lightbox): a caption ending in a wide image no longer grows when the window widens - #11740

Merged
cixzhang merged 8 commits into
meta:mainfrom
mahmed74:fix/lightbox-caption-wide-block-image-resize
Nov 14, 2026
Merged

cixzhang merged 8 commits into
meta:mainfrom
mahmed74:fix/lightbox-caption-wide-block-image-resize

Conversation

@mahmed74

@mahmed74 mahmed74 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #11598

User impact

Anyone using a Lightbox gallery whose caption ends in a block-level box that is wider than the room beside "less", such as a full-width image. They open the caption with "more" on a narrow screen. Widening the window, for example by rotating a phone, makes the caption's text block grow by a line every frame. In the issue's repro it reached 17 lines, and "less" ended up off the line the layout reserves for it. A fresh open of the same caption is also wrong: a 6-line caption was given a float of about 19 lines.

Problem and solution fit

  • Why it happens: an open caption reserves room for "less" with a float. The float's length (-webkit-line-clamp) comes from the caption's measured height. A block image wider than the room beside the float cannot sit next to it, so it drops below the float. The next measure then counts the float's lines plus the image's, and that count becomes the float's new length. Each delivery adds the image's lines, so the caption grows without end. The existing shrink path cannot stop it, because it reads the same inflated flow height.
  • Why it harms the task: the open caption is taller than its content, with a blank gap, and "less" is not on the last line. A caption that keeps growing can also reach the 60 % height cap and start to scroll for no reason.
  • Why it matters: the caption is the viewer's accessible description. Content that moves with every resize is hard to read and breaks the layout promise made for "less".

The fix removes the feedback. When a block-level box starts at the float's bottom edge, the caption reads its lines once without the float, so the count no longer includes the float. It then keeps the float out of the flow while the caption is open, and "less" takes the line below the image. That is the outcome the issue asks for.

A block that starts at the float's bottom edge only because the text ends on the float's last line (an empty block, a thin rule, a 1×1 image) is not pushed down by the float. The caption leaves those alone: the float stays on, and "less" stays on the last line. The float turns off only when the block's top is more than half a line below the end of the text.

Expected behavior and authority

Smallest restoration

  • Lightbox.tsx: one new check in measureCaptionLines, a captionPlaceOff state, and one style, captionTextToggleOwnLine. The place is shown only while the caption is open (isCaptionOpen && isCaptionPlaceOff), so the closing render does not lay out without it. A caption with no block at the float's bottom edge takes exactly the previous path.
  • No new public API, data-* attribute, visual representation, default or interaction model.
  • Stories: adds CaptionEndingInWideImage, CaptionEndingInTallImage and CaptionEndingInShortBlock, which the regression tests open.
  • Known limitation: once the float is off, it stays off while that caption is open. If a later width would let the block fit beside "less", "less" stays on its own line.

Evidence

  • Reproduction before the change: story CaptionEndingInWideImage, Chromium at 360×874 with touch. Open the viewer, tap "more", then widen to 362px. The text block grows every frame (14 lines in the new spec, climbing in the manual trace). A fresh open at 360–420px gives a float of 18–20 lines for 6 lines of content.
  • Result after the change: the text block is 7 lines at every width and in every frame, the same as a fresh open at that width. "less" sits on its own line below the image. This holds in LTR and RTL. Closing the caption ("less") no longer raises a ResizeObserver loop error.
  • Representative unchanged path: plain text, small block image and inline-image captions show the same float state and line counts as before the change at 360–420px, in LTR and RTL.
  • New cases in LightboxViewport.a11y.browser.spec.ts, run in Chromium and WebKit:
    • the wide-image caption keeps its lines when the window widens (360 → 362, 364 and 420 px)
    • "less" takes the line below the wide image
    • open and close raise no ResizeObserver loop error, for the wide-image, tall-image and short-block stories
    • "more" shows a caption that ends in a tall image at its final height in every frame after the tap
    • "less" stays on the last line of text beside a short block

The count of failures without the fix is not confirmed yet. Re-run those specs against a build without the fix, then state it here.

Scope

Components: Lightbox

  • 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

  • pnpm exec vitest run packages/core/src/Lightbox --project ui: 175 of 175 pass.
  • pnpm storybook:build, then pnpm exec playwright test --config playwright.config.ts packages/core/src/Lightbox/LightboxViewport.a11y.browser.spec.ts: 74 of 74 pass in Chromium and WebKit.
  • Eight caption shapes, LTR and RTL, each resized through five widths against a dev server: all 16 runs matched a fresh open, with no ResizeObserver errors. The shapes were plain text, small block image, inline image, wide block image, tall wide image, image mid-caption, two wide images, and a short caption plus a wide image.
  • tsc, eslint and prettier are clean on the changed files, and pnpm check:repo passes.
  • Not caused by this change: the other Lightbox browser specs have failures that also occur on a build without the fix, on a Windows machine. They are the LightboxFinePointer focus-ring width (Chromium and WebKit), the WebKit "less" focus check in LightboxKeyboard, and about two dozen zoom, dismiss and frame-timing checks in the interaction suite. CI on Linux should confirm that.
  • Overlap: fix(Lightbox): an open caption shrinks without a forced layout #11539 also changes measureCaptionLines. This pull request lands first, as a fix for a shipped regression; fix(Lightbox): an open caption shrinks without a forced layout #11539 then merges main and resolves the overlap.

Writing rubric results

R1 narration: none; PR2 states in the present tense why the caption's measurement is Lightbox's own.
R2 research: none in the record; the browser measurements stay in this description.
R3 evidence: PR2 names a record and a module, not a pull request, issue or commit.
R4 rejected alternatives: none added.
R5 change references: none.
R6 open questions: none added; the record's open questions are unchanged.
R7 project status: none; the follow-up to extend useTruncation is tracked outside the record.

Maintainer round 1 (fix loop, lane 4)

Credited maintainer edits on top of @mahmed74's commits. The fix, its diagnosis and the wide-image and short-block cases are @mahmed74's; this round adds the tall-block case.

  • Why: with a trailing block taller than about a line and a half, such as a 400×120 image, each "more" raised a ResizeObserver loop error and showed one frame of a taller caption with a blank gap. The open caption's count set the toggle's place from the flow's lines, block included, so the place pushed the block down, and the first resize delivery then turned the place off and changed the caption's height inside that delivery.
  • Change: the open caption's count, which already reads the flow without the place, now also decides the place's state, once per open. A box that keeps clear of floats (a block-level replaced element, or a box with its own formatting context) and is wider than the room beside the place, and that the place would push down by half a line or more, keeps the place off from the first frame. The first resize delivery then finds the caption at its final size. The tap still takes one layout read, as before.
  • Later widths: a width change after the open that pushes a block below a shown place turns the place off in the next frame, not inside the resize delivery.
  • Tests: a CaptionEndingInTallImage story; it joins the loop-error cases, and a new case reads the caption's height in each frame after "more" and checks that no frame is taller than the final one.
  • Checks: pnpm exec vitest run packages/core/src/Lightbox: 175 of 175 pass. tsc and eslint are clean.
  • Real browser, this head (Chromium, Playwright 1.61.1): LightboxViewport.a11y.browser.spec.ts 42 of 42 and LightboxPaging.interaction.browser.spec.ts 33 of 33 pass.
  • Red, then green (each case run 3 times, no retries): on the contributor's last head with this head's story and spec files, "caption-ending-in-tall-image opens and closes cleanly" fails 3 of 3 ("ResizeObserver loop completed with undelivered notifications") and "'more' shows a caption that ends in a tall image at its final height in every frame" fails 3 of 3 (frame 0 is 337.4 px against a final 265.4 px). Both pass 3 of 3 at this head.
  • Before and after (headed Chromium, a 360×874 phone with touch; before is main with this head's story file):
    • Wide image, widened 360 → 362 px: this head keeps 7 lines, the same as a fresh open at 362 px, and "less" sits on its own line directly below the image. On main the caption box is 19 lines tall and stays 19 after the widen.
    • First frame at 360×874: this head shows a 177 px caption (text, image, "less" below it); main shows a 465 px box with blank space.
    • Tall image, the caption's height in each of 30 frames after "more": this head is 265.4 px in every frame with no loop error. The contributor's last head is 337.4 px in frame 0, then 265.4 px, with one error. main never settles (337 → 433 → 524 → 256 → …, 162 loop errors in about 2.5 s).

Before and after at this head, main on the left: captions ending in a flex row and a clipped block ("less" beside, as on main), a caption ending in a wide image at 360 px, widened to 362 px and opened fresh, and a caption ending in a tall image after "more", with its height in each of 30 frames

tall-image caption, height after "more" frames 0 → 29 ResizeObserver loop errors
main 337 → 433 → 524 → 256 → 361 → 457 → 524 → 256 → … (never settles) 162
contributor's last head 337 in frame 0, then 265 1
this head 265 in every frame 0

Maintainer round 2

  • Why: round 1 counted any box that keeps clear of floats and is wider than the room beside the toggle's place as pushed below it. But a block with no set width, such as a flex row or a block that clips its overflow, narrows to sit beside the place. So for captions ending in such a block, round 1 moved "less" to a line of its own at every width, where main keeps it beside the last line.
  • Change: only a block-level replaced element (an image, a video, a canvas, an embedded frame), which keeps its own width, turns the place off at the open. Any other block narrows beside the place, as on main. A box that is pushed down later, at a new width, is still caught by the contributor's check in the resize delivery and handled in the next frame.
  • Tests: two sweep cases from @vjeux (captions ending in a flex row and in a clipped block, widened from 360 px to each width that leaves their text one line fewer; they fail on round 1 and pass on main), committed under @vjeux's name; and two stories (CaptionEndingInFlexRow, CaptionEndingInClippedBlock) with cases at 362, 400 and 420 px that check "less" stays beside the last block.
  • Record: Lightbox's PR2 names why the caption's measurement is Lightbox's own: useTruncation reports only whether a clamped block overflows, and no shared engine counts an unclamped block's laid-out lines or places an inline float beside its last line (architecture:react-component-runtime INV19).
  • Checks: pnpm exec vitest run packages/core/src/Lightbox: 175 of 175 pass; tsc, eslint with no warnings, Prettier and pnpm check:knowledge are clean.
  • Real browser, this head: LightboxViewport.a11y.browser.spec.ts 48 of 48 in Chromium and in WebKit (the flex-row and clipped-block cases at 362, 400 and 420 px included); LightboxPaging.interaction.browser.spec.ts 35 of 35 in Chromium, and in WebKit 31 pass with 4 skipped (those 4 are Chromium-only by their own declaration). @vjeux's two sweep cases pass in both engines here; on round 1 they fail in both engines from 362 px, and on main they pass.
  • Stills (the sheet above): for the flex-row and clipped-block captions "less" sits beside its place at 360, 362 and 364 px, the same as main. The wide-image and tall-image results match round 1.

Co-authored-by: ahmed-technyx

Owner: fix-loop lane 4 (maintainer carry). Land path: lands before #11539 (a shipped regression); after the real-browser runs and stills, Specs, CodeBunny, CI, and the drain merges.

… lines when the window widens

An open caption reserves room for "less" with a float whose length comes
from the caption's own height. A block image wider than the room beside
that float cannot sit next to it, so it drops below the float. The
caption's height then counts the float and the image, the float grows by
the image's lines, and the caption grows again in the next delivery.
Widening the window ran this loop until the text block was 17 lines tall.
A fresh open ran it too: a 6-line caption got a float of about 19 lines.

When a block-level box starts at the float's bottom edge, the caption
now reads its lines once without the float a
the flow while it stays open. "less" takes the line below the image. A
caption with no such block takes the same path as before.

Adds a regression spec: after widening, the open caption has the same
line count as a fresh open at that width for 10 frames, and "less" sits
below the image. Adds the CaptionEndingInWid

Fixes meta#11598
@vercel

vercel Bot commented Nov 14, 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 5:29pm UTC

Request Review

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

astracat-bot Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

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

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Nov 14, 2026
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 04ad951

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
lab/CommentThread 360.9 kB (+646 B) · 2.4 kB CSS (0) — — · — · —
lab/Comments 368.2 kB (+627 B) · 2.5 kB CSS (0) — — · — · —
Lightbox · Storybook 145.7 kB (+587 B) · 11.9 kB CSS (+13 B) 5,046 (+371) ✓ · ✓ · ✓

Package size: @astryxdesign/core 7.57 MB packed (+3.8 kB); 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

@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: the fix works (an open caption that ends in a wide block image keeps its lines when the window widens, "less" sits below the image, and the two new tests fail without the fix and pass with it), but one change is needed before approval:

  • measureCaptionLines hides the toggle's place, reads the caption's height, restores the place and then reads scrollHeight in the same resize delivery (Lightbox.tsx lines 1024–1027 and 1069–1072), which forces two extra page layouts each time such a caption opens and breaks react-component-runtime INV18's "never interleaved with writes", so please count the text's lines from reads alone (for example a Range over the caption text plus the block's height) and extend the existing "no caption read follows a write in the same resize delivery" test to the new story.

A wording fix for the comment at lines 1007–1009 is suggested inline, and CI has not run on this head yet, so a maintainer adds the ci:run label for it to run.

Claims and files checked
  • Changeset, the open caption keeps its lines when the window widens: verified (new tests fail without the fix and pass with it; 8 lines in each of ten frames after 360 → 362 px, against 17 to 21 before).
  • Changeset, "less" takes the line below the image: verified (its top meets the image's bottom; new test).
  • Description, a fresh open was also oversized: verified (a 12-line float for six text lines at 360 px; the exact count depends on fonts).
  • Description, the line count after the fix matches a fresh open: verified; here 8 lines at 362 px and 7 at 420 px rather than 7 at every width, which depends on fonts.
  • Description, captions without a block at the float's edge keep the previous path: verified (identical frames for a plain caption and the clamped caption; existing caption suites pass).
  • Description, right-to-left holds: verified for the open state.
  • Description, no new public API, data attribute, default or interaction model: verified (built API surface unchanged by this change).
  • Description, the place stays off until the caption closes: verified in code.
  • Description, unit and viewport tests pass: verified in Chromium (175/175 and 37/37); WebKit not run.
  • Description, lint and formatting clean: verified (eslint, prettier, changeset check).
  • packages/core/src/Lightbox/Lightbox.tsx: the blocking finding above, plus the comment suggestion.
  • packages/core/src/Lightbox/LightboxViewport.a11y.browser.spec.ts: clear.
  • apps/storybook/stories/Lightbox.stories.tsx: clear.
  • .changeset/lightbox-an-open-caption-that-ends-in-a-block-im-2vsm.md: clear.

Automated review (maintainer link)

Comment thread packages/core/src/Lightbox/Lightbox.tsx Resolved
Comment thread packages/core/src/Lightbox/Lightbox.tsx Resolved
The wide-block-image measure hid the toggle's place, read the flow, and
restored it, which forced extra layouts in the resize delivery. It now
reads the text before the block with a Range and the height below the
block's top, so no read follows a write. The no-late-read test covers the
wide-image story and now sees writes to an element's style display.

Also rewords the place-off comment to match the known limitation.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

@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. The fix works for the wide-image caption (it keeps its lines when the window widens, "less" sits below the image, and the two new tests fail without the fix and pass with it), and the earlier forced-layout issue is fixed, but two changes are needed:

  • Miss: measureCaptionLines treats any block whose top meets the toggle place's bottom as pushed below it, so a caption that ends in a block shorter than half a line (an empty block, a thin rule, a 1×1 image) now moves "less" off its last line, grows by a line and raises "ResizeObserver loop completed with undelivered notifications" on open and close; please count the block as below the place only when its top lies below the end of the text before it (Lightbox.tsx lines 1014–1025).
  • Miss: isCaptionPlaceOff stays true into the render that closes the caption, so every "less" on the new story raises one ResizeObserver loop error; using isCaptionOpen && isCaptionPlaceOff for hasCaptionTogglePlace and the padding style (lines 1804–1805 and 2020–2024) removes it, and the new tests can add the existing loop-error check.

With both corrections, the short-block captions match the base and the new tests still pass. CI has not run on this head yet; a maintainer adds the ci:run label for it to run.

Claims and files checked
  • Title and changeset, an open caption ending in a wide block image keeps its lines when the window widens: verified (8 lines in every frame after 360 → 362 px, against 14 climbing to 21 before).
  • Changeset, "less" takes the line below the image: verified (its top meets the image's bottom; new test).
  • Description, a fresh open on the base was oversized: verified (14 lines for six lines of text at 360 px; the count cycles and depends on fonts).
  • Description, after the fix the count matches a fresh open at each width: verified (8 lines at 360–362 px and 7 at 420 px here, rather than 7 at every width).
  • Description, right-to-left holds: verified.
  • Description, plain-text, small block image and inline-image captions keep their float state and line counts: false for a block shorter than half a line (first finding); verified for plain text, an inline image and a 40×40 block image.
  • Description, the two new tests fail without the fix and pass with it: verified in Chromium; WebKit not run here.
  • Description, the unit tests and the Lightbox viewport spec pass: verified in Chromium (175 of 175, 37 of 37).
  • Description, resizing the caption shapes raises no ResizeObserver errors: verified for the resize steps tried; the errors in the findings come from opening and closing.
  • Description, tsc, eslint, prettier and the repository checks are clean: verified for tsc and prettier, and for eslint with no errors and one warning in the new test proxy; the repository checks pass up to the executable-bits step, which needs a git checkout that was not available.
  • Description, no new public API, data attribute, default or interaction model: verified (built surfaces unchanged).
  • Description, the place stays off until the caption closes: verified in code.
  • Description, draft #11539 edits the same measure: verified.
  • packages/core/src/Lightbox/Lightbox.tsx: the two findings above, plus two comment wording suggestions.
  • packages/core/src/Lightbox/LightboxViewport.a11y.browser.spec.ts: clear.
  • packages/core/src/Lightbox/__tests__/LightboxPaging.interaction.browser.spec.ts: clear.
  • apps/storybook/stories/Lightbox.stories.tsx: clear.
  • .changeset/lightbox-an-open-caption-that-ends-in-a-block-im-2vsm.md: clear.

Automated review (maintainer link)

Comment thread packages/core/src/Lightbox/Lightbox.tsx Resolved
Comment thread packages/core/src/Lightbox/Lightbox.tsx Resolved
…losing render

A trailing block shorter than half a line no longer turns the toggle's
place off, and the place-off state applies only while the caption is open.
Adds a short-block story and loop/position specs.

@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. The fix works for the story's caption: an open caption that ends in a wide block image now keeps the line count a fresh open gives when the window widens, "less" sits on its own line under the image, the wide-image tests fail without the fix and pass with it, and both earlier findings (short trailing blocks and the closing render) are fixed. One change is needed:

  • Miss: when the trailing block is taller than about a line and a half (a full-width image, say), every "more" still raises "ResizeObserver loop completed with undelivered notifications" and shows one frame of a taller caption with a blank gap, because countOpenCaption counts the block's lines into the toggle's place and the first resize delivery then turns the place off and changes the caption's height (Lightbox.tsx lines 1057–1062); deciding the place's state in the click path, and running the new loop-error test on a block taller than two lines, would fix it.

Please also bring the description up to date with the second story and the five new viewport cases. CI has not run on this head yet; a maintainer adds the ci:run label for it to run.

Claims and files checked
  • Changeset, an open caption ending in a block image wider than the room beside "less" keeps its text lines when the window widens instead of growing every frame: verified (7 lines in every frame after 360 → 362 px and 6 at 420 px, matching a fresh open; before the fix it climbs from 14 to 21).
  • Changeset, "less" takes the line below the image: verified (new test; frames at 360 px in both directions).
  • Description, the block drops below the float and its lines lengthen the float, so a fresh open was already oversized: verified (before the fix the caption climbs a line per frame from the first open).
  • Description, a caption with no block at the float's bottom edge takes the previous path: verified in code (Lightbox.tsx lines 1012–1025) and by probes.
  • Description, no new public API, data attribute, default or interaction model: verified (built surfaces unchanged).
  • Description, the float stays off while that caption is open: verified in code (line 1011).
  • Description, after the fix the count matches a fresh open at each width, in left-to-right and right-to-left: verified (7 lines at 360–362 px and 6 at 420 px here, rather than 7 at every width).
  • Description, plain-text, small block image and inline-image captions keep their float state and line counts: verified (plain text through the existing spec; 40×40, 1×1, inline and inline-block images and a short block match the earlier behavior).
  • Description, the two new wide-image cases fail without the fix and pass with it: verified in Chromium; WebKit not run here.
  • Description, the Lightbox unit tests pass (175 of 175): verified.
  • Description, the viewport spec passes: verified in Chromium, 40 of 40 at this head (the description's 74 predates the last commit).
  • Description, eight caption shapes resize with no ResizeObserver errors: false for the tall wide image, which raises one on each "more" (the finding above); verified for 16 px and 30 px images and the unchanged shapes.
  • Description, tsc, eslint, prettier and the repository checks are clean: prettier clean; eslint has no errors and one warning in the new style proxy; the Core build type-checks Lightbox.tsx; the changeset check passes; the full repository checks were not run here.
  • Description, draft #11539 also changes measureCaptionLines: verified.
  • packages/core/src/Lightbox/Lightbox.tsx: the finding above, plus three comment wording suggestions.
  • packages/core/src/Lightbox/LightboxViewport.a11y.browser.spec.ts: clear.
  • packages/core/src/Lightbox/__tests__/LightboxPaging.interaction.browser.spec.ts: clear (one lint warning).
  • apps/storybook/stories/Lightbox.stories.tsx: clear.
  • .changeset/lightbox-an-open-caption-that-ends-in-a-block-im-2vsm.md: clear.

Automated review (maintainer link)

Comment thread packages/core/src/Lightbox/Lightbox.tsx Resolved
Comment thread packages/core/src/Lightbox/Lightbox.tsx Resolved
Comment thread packages/core/src/Lightbox/Lightbox.tsx Resolved
Comment thread packages/core/src/Lightbox/Lightbox.tsx Resolved
…esize delivery

The open caption's count reads the flow without the toggle's place. It
now also decides there whether the place, shown with the flow's lines,
would push a block down: a block-level replaced element or a box with its
own formatting context that is wider than the room beside the place.
Then the place stays off from the first frame, so the first resize
delivery finds the caption at its final size. A width change after the
open that pushes a block below a shown place turns the place off in the
next frame, not inside the delivery. A story ends a caption in a tall
image, and the browser tests check it for a loop error and for a taller
frame after "more".

Co-authored-by: ahmed-technyx <[email protected]>
@cixzhang
cixzhang marked this pull request as draft November 14, 2026 15:33
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 14, 2026
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec de143e0

@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 14, 2026
cixzhang added a commit that referenced this pull request Nov 14, 2026
@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 14, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: an open caption that ends in a wide block image now keeps a fresh open's line count, with "less" under the image and no ResizeObserver loop error, but the new open-time check regresses captions that end in a flex row.

  • Blocking: a caption that ends in a flex row, a flow-root box or another box with its own formatting context now drops "less" to a line of its own and grows by a line (7 → 8 lines at 360 px), because keepsClearOfFloats and wouldPlacePushBlock (Lightbox.tsx:621-627, :658) treat such a box as pushed below the place, while an auto-width one narrows beside it, as it does on main.

Testing the width only of replaced elements at open (the resize check still catches anything the place really pushes down) and adding a flex-row case next to the short-block test would fix it; the inline comments have the details. As the description's known limitation says, widening the window after opening still keeps "less" on its own line.

Claims and files checked

Claims:

  • An open caption that ends in a wide block image no longer grows when the window widens: verified (a 400 × 16 image at 360 px climbs from 165 to 405 px over ten frames on main and holds at 189 px here).
  • A fresh open on main is oversized too: verified (it climbs from the first frame).
  • "less" takes the line below the image: verified (its top meets the image's bottom, in both directions).
  • Short trailing blocks keep "less" on the last line: verified (a 2 px block and a 400 × 8 image render as on main).
  • A caption with no block at the float's bottom edge takes the previous path: false for a flex-row or flow-root ending (the blocking finding).
  • No new public API, data attribute, default or interaction model: verified (built API surface and source).
  • Three new stories, opened by the new tests: verified.
  • Once off, the place stays off while the caption is open: verified (the known limitation).
  • Every width matches a fresh open, left to right and right to left, and closing raises no loop error: verified (the line counts depend on fonts: 8, 8 and 7 here at 360, 362 and 420 px).
  • Plain-text and small-block captions are unchanged: verified; inline images not checked.
  • A tall trailing image opens at its final height with no loop error: verified for 40, 120 and 225 px images.
  • A later width that pushes a block down turns the place off in the next frame: verified (a 330 px image from 420 to 360 px, no error).
  • The Lightbox unit suite passes, 175 of 175: verified.
  • ESLint and Prettier are clean on the changed files: verified (one lint warning in a test file).
  • The browser specs pass in Chromium and WebKit, the repository checks pass, and the other browser failures predate the change: not re-run; CI has not run on the draft.
  • Changeset: such a caption keeps its lines when the window widens, and "less" takes the line below the image: verified.

Files:

  • packages/core/src/Lightbox/Lightbox.tsx: the blocking finding; two comment suggestions.
  • packages/core/src/Lightbox/LightboxViewport.a11y.browser.spec.ts: clear (no case for a flex-row ending).
  • packages/core/src/Lightbox/__tests__/LightboxPaging.interaction.browser.spec.ts: clear.
  • apps/storybook/stories/Lightbox.stories.tsx: clear.
  • .changeset/lightbox-an-open-caption-that-ends-in-a-block-im-2vsm.md: clear.

Automated review (maintainer link)

Comment thread packages/core/src/Lightbox/Lightbox.tsx Resolved
Comment on lines +1024 to +1027
// Whether a block in the open caption sits below the toggle's place, as a
// wide image does. The place then makes the caption taller, and the taller
// caption makes the place longer, so the place is not shown and the toggle
// takes the line below the caption.

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 (comment style): the second sentence has 31 words and a passive "is not shown". Suggested:

// Whether the toggle's place would push a block in the open caption below
// it, as a wide image. The place then makes the caption taller, and the
// caption makes the place longer. So the place stays off, and the toggle
// takes a line of its own under the caption.

cixzhang and others added 2 commits November 14, 2026 09:13
… off

A block with no set width narrows to sit beside a float, so a caption
that ends in a flex row or a block that clips its overflow keeps "less"
beside it, as before. Only a block-level replaced element, such as an
image, keeps its width and drops below the place. Stories end captions in
a flex row and a clipped block, and tests check that "less" stays beside
them. Lightbox's record names why its caption measurement is its own, and
a test's style proxy states its return type.

Co-authored-by: ahmed-technyx <[email protected]>
Two captions end in a block with a layout of its own: a flex row, and
a block that clips its overflow. Such a block narrows beside the
toggle's place, so "less" takes a line of its own only where it does
not fit beside the last line, as with plain text. The sweep widens an
open caption from 360 px to each width that leaves its text one line
fewer. It fails where "less" leaves its place or moves a word.
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 14, 2026
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 04ad951

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 14, 2026
cixzhang added a commit that referenced this pull request Nov 14, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the caption fix checks out, but the record edit needs its writing-rubric results. An open caption that ends in a wide block image now holds its height from the first frame, with "less" on its own line under the image and no ResizeObserver loop error, and every earlier blocking finding is fixed.

  • Blocking: the pull request adds PR2 to the Lightbox record (docs/specs/components/Lightbox/Lightbox.spec.md:210-215), and the knowledge-contracts record requires a pull request that changes a record to report the writing rubric's results in its description under ## Writing rubric results, which this description does not have.

PR2 reads clean against the rubric, so seven short lines will do; the inline comment has a draft. While editing the description, its Testing section says #11539 lands first, which contradicts the land path at the end.

Claims and files checked

Claims:

  • Changeset: such a caption keeps its text lines when the window widens instead of growing every frame: verified (the new widening case fails on the base and passes here; a 400 × 16 image holds 201 px where the base climbs to 465 px).
  • Changeset: "less" takes the line below the image: verified (its top meets the image's bottom, in both directions).
  • A fresh open on the base is oversized too: verified (it climbs from the first frame).
  • Short trailing blocks keep "less" on the last line: verified (a 2 px block renders as on the base).
  • Captions with no block at the float's bottom edge take the previous path: verified (plain, flex-row, clipped-block, inline-image and flex-with-image endings are pixel-identical to the base).
  • Only a block-level replaced element turns the place off at open, and flex rows and clipped blocks narrow beside "less": verified (code, six viewport cases, two width sweeps).
  • A tall trailing image opens at its final height with no loop error: verified (289 px in every frame; the base cycles between 256 and 524 px).
  • A later width that pushes a block below a shown place turns the place off in the next frame: verified by reading the code.
  • Once off, the place stays off while the caption is open: verified (the known limitation).
  • No new public API, data attribute, default or interaction model: verified (built API surface and source).
  • New stories that the tests open: verified (five stories and two fixtures).
  • Failures without the fix: 5 of the 13 new viewport cases fail on the base.
  • Lightbox unit suite, 175 of 175: verified.
  • Browser specs pass: verified in Chromium (48 viewport and 35 paging cases); WebKit not run; "74 of 74" counts an earlier head.
  • TypeScript, ESLint, Prettier and the knowledge check are clean: verified.
  • Other Lightbox browser failures predate the change: not checked; CI has not run on the draft.
  • The new PR2 record clause: present and approved by an engineering owner at this head; its rubric results are missing (the blocking finding).
  • #11539 lands first: contradicted by the description's own land path; #11539 is still an open draft.

Files:

  • docs/specs/components/Lightbox/Lightbox.spec.md: the blocking finding (rubric results missing from the description).
  • packages/core/src/Lightbox/Lightbox.tsx: clear; one comment suggestion still open.
  • packages/core/src/Lightbox/LightboxViewport.a11y.browser.spec.ts: clear.
  • packages/core/src/Lightbox/__tests__/LightboxPaging.interaction.browser.spec.ts: clear.
  • apps/storybook/stories/Lightbox.stories.tsx: clear.
  • .changeset/lightbox-an-open-caption-that-ends-in-a-block-im-2vsm.md: clear.

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet because the pull request is a draft, and marking it ready for review starts the run (it already carries ci:run). An open caption that ends in a wide block image now holds its height from the first frame, with "less" on its own line under the image, and the writing-rubric results for the Lightbox record's new performance clause are now in the description and match the clause.

  • Optional: the Testing section's "74 of 74" and the Evidence section's "not confirmed yet" describe an earlier head; the round 2 counts and the red-then-green run are the current ones.
Claims and files checked

Claims:

  • Title and changeset: a caption ending in a wide block image keeps its text lines when the window widens instead of growing every frame: verified (the widening case fails on the base and passes here).
  • Changeset: "less" takes the line below the image: verified (its top meets the image's bottom, in both directions).
  • A fresh open on the base is oversized too: verified (the base climbs from the first frame).
  • The diagnosis (the float's length counts the block's lines, so each measure lengthens it again): verified by reading the code.
  • Short trailing blocks keep "less" on the last line: verified (the 2 px block case passes on both trees).
  • Captions with no qualifying block take the previous path: verified (plain, flex-row, clipped-block and inline-image endings render pixel-identically to the base).
  • Only a block-level replaced element turns the place off at open, and flex rows and clipped blocks narrow beside "less": verified (code, six viewport cases, two width sweeps).
  • A tall trailing image opens at its final height with no loop error: verified (the per-frame height case and the loop-error case).
  • A later width that pushes a block below a shown place turns the place off in the next frame: verified by reading the code.
  • Once off, the place stays off while the caption is open: verified (the known limitation).
  • Expected behavior follows the issue and the Lightbox record's inline-toggle clause: verified.
  • No new public API, data attribute, default or interaction model: verified (built API surface and source).
  • New stories that the tests open: verified (five stories and two fixtures).
  • The record's new performance clause says why the measurement is Lightbox's own: present, and approved by an engineering owner at this head.
  • Writing rubric results R1 to R7: verified against the clause's text.
  • Lightbox unit suite, 175 of 175: verified.
  • Viewport 48 of 48 and paging 35 of 35: verified in Chromium; WebKit not run; "74 of 74" counts an earlier head.
  • Failures without the fix: 5 of the 13 new viewport cases fail on the base.
  • TypeScript, ESLint, Prettier and the knowledge check are clean: verified.
  • The repository check and the eight-shape manual sweep: not checked.
  • Other Lightbox browser failures predate the change: not checked; CI has not run on the draft.
  • This pull request lands before #11539: consistent throughout the description; #11539 is still an open draft.

Files:

  • packages/core/src/Lightbox/Lightbox.tsx: clear; two comment-style suggestions.
  • packages/core/src/Lightbox/LightboxViewport.a11y.browser.spec.ts: clear.
  • packages/core/src/Lightbox/__tests__/LightboxPaging.interaction.browser.spec.ts: clear.
  • apps/storybook/stories/Lightbox.stories.tsx: clear.
  • docs/specs/components/Lightbox/Lightbox.spec.md: clear (approved clause; rubric results in the description).
  • .changeset/lightbox-an-open-caption-that-ends-in-a-block-im-2vsm.md: clear.

<!-- codebunny-mode: same-head; reason: none -->

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 14, 2026 18:49
@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Nov 14, 2026
@cixzhang
cixzhang merged commit 5628141 into meta:main Nov 14, 2026
156 checks passed

This branch was successfully deployed

1 active deployment
Preview — 04ad9515 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

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Lightbox: an open caption ending in a wide block image grows to 17 lines when the window widens

3 participants