Skip to content

fix(Lightbox): the viewer fits the visible viewport, so Safari's toolbar no longer covers its caption - #8732

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/c27-lightbox-dvh
Oct 27, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/c27-lightbox-dvh

Conversation

@vjeux

@vjeux vjeux commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

User impact

On an iPhone, Safari's bottom toolbar covers the bottom of an open Lightbox. A photo tall enough to fill the viewer pushes its caption there, unseen, and a tap where it sits reaches Safari instead. Measured in Mobile Safari, iOS 26.2, iPhone 17 Pro, on main's gallery story with a 1:3 portrait photo: the visible viewport is 714 pt, the viewer 754 pt, and the caption spans 718–754.

Problem and solution fit

  • Why does it fail? The viewer's dialog is height: 100vh. In Mobile Safari 100vh is the large viewport, measured with the toolbars retracted, so the dialog runs past the visible area by the bottom toolbar's height.
  • Why does that harm the task? The caption is the lowest part of the viewer, so it is the first to disappear, with the text that describes the photo.
  • Why does that matter? Captions carry content the caller chose to show with each item.

The fix sizes the dialog to the dynamic viewport, 100dvh: the height the browser shows. An engine without dvh keeps 100vh.

Expected behavior and authority

Lightbox.doc.mjs documents the caption as "displayed below the active media". The draft component:Lightbox record describes "a full-viewport viewer" (context only: draft, not authority). CSS Values 4 defines dvh as the dynamic viewport, the size with the browser's current toolbars.

Smallest restoration

One declaration, height: stylex.firstThatWorks('100dvh', '100vh'). The width stays 100vw; no other style, API or behavior changes.

Evidence

  • Reproduction before the change: iPhone 17 Pro simulator, iOS 26.2, main ad427c2. The viewer is 754 pt tall and the caption spans 718–754, below the 714 pt visual viewport.
  • Result after the change: the viewer is 714 pt, the visible height, and the caption spans 678–714. A wide photo's group moves up 20 pt, centred in the visible area.
  • Representative unchanged path: in desktop Chromium and WebKit 100dvh equals 100vh; the Lightbox browser specs and unit tests pass unchanged.
  • Regression test or other mutation-sensitive proof: LightboxViewport.a11y.browser.spec.ts requires the viewer to declare 100dvh. On main it fails in both engines, reading ["100vh"]. No desktop or emulated engine shrinks the dynamic viewport (Chromium's small-viewport override moves only svh; dvh, lvh and vh stay at the window height), so the simulator measurement above proves the geometry.

Scope

  • 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 playwright test --config playwright.config.ts packages/core/src/Lightbox/*.a11y.browser.spec.ts on the built Storybook: Chromium 3/3, WebKit 3/3. The new spec failed on main in both engines, reading ["100vh"].
  • pnpm vitest run packages/core/src/Lightbox/: 61 pass. Core typecheck: 0 errors. CI=true eslint over packages/core/src/Lightbox: 0 problems. pnpm check:repo passes; the CI duration guard passes.
  • iPhone 17 Pro simulator, iOS 26.2, Mobile Safari, on main ad427c2 and on this head: the viewer's and the caption's boxes against visualViewport.height, with the gallery story's wide photo (caption at 493–529 on main, 473–509 here) and with a 1:3 portrait photo.
  • Size (import {Lightbox}, gzip): JS 52,567 → 52,567 B, CSS 10,015 → 10,022 B.
  • merge-tree against main ad427c2: clean.

…bar no longer covers its caption

The viewer's dialog was 100vh tall. In Mobile Safari 100vh is the large
viewport, measured with the toolbars retracted, so the dialog ran under the
bottom toolbar and hid a gallery's caption (iOS 26.2, iPhone 17 Pro: 714 pt
visible, the caption at 718-754). It is now 100dvh, the dynamic viewport,
with 100vh where an engine lacks dvh. A browser spec requires the declared
dvh: no desktop or emulated engine shrinks the dynamic viewport.
@vercel

vercel Bot commented Oct 27, 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 Oct 27, 2026 6:57pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 27, 2026, 7:22 PM UTC

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Oct 27, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 27, 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.

Automated review found no blocking issues: sizing the Lightbox dialog with 100dvh, falling back to 100vh, keeps the caption above Mobile Safari's bottom toolbar without changing any API or how other browsers render the viewer. The iPhone simulator measurements in the description are the real-browser evidence this fix needs, and the new browser spec catches a return to 100vh. Nothing further is needed from you.

[Automated review]

@cixzhang
cixzhang merged commit 343fddd into meta:main Oct 27, 2026
59 checks passed
@vjeux
vjeux deleted the uikit/c27-lightbox-dvh branch October 27, 2026 20:41
cixzhang pushed a commit that referenced this pull request Oct 31, 2026
#9064)

## Maintainer impact

`LightboxViewport.a11y.browser.spec.ts` checks that the open viewer declares `height: 100dvh` by reading the page's stylesheets. Each sheet's walk sat inside an empty `catch`, meant for a cross-origin sheet whose rules a page can't read. That catch swallowed every other error too, so a same-origin sheet that failed to read was skipped in silence: the proof could pass on CSS it never read, or fail on a missing `100dvh` that hid the real error.

## Intended invariant

The proof's claim is unchanged: the open viewer declares `height: 100dvh`, so Safari's toolbar can't cover its caption (#8732). Only how it skips an unreadable sheet changes.

## Change

The walk now skips only a sheet whose `href` resolves to another origin, and reads every other sheet with no `catch`, so any other error fails the proof. One test file and no product code, so no changeset.

Found while auditing the Lightbox proofs for catch blocks that could hide a failure. Prior art: no open pull request touches this spec (searched open pull requests for `LightboxViewport`, `cross-origin stylesheet` and `styleSheets catch`).

## Evidence

- Failure before the change: with a read error injected into each same-origin sheet that lacks the `100dvh` rule, the spec on main passes; injected into every sheet, it fails on "expected [] to contain '100dvh'" rather than on the error.
- Success after the change: both injections fail on the injected error, and without one the spec passes 2 of 2 in Chromium and in WebKit.
- Product/runtime behavior verified unchanged: test-only change; the UI and node suites pass as on main.

## Scope

- [x] No intended public API, product behavior, visual direction, or policy change.
- [x] Product changes discovered during the work were removed or split.
- [x] Public text and artifacts contain no internal Meta context.

## Testing

Local gates at fd830f7 (on main d73908f):

- `pnpm check:repo`, `pnpm typecheck` (0 errors), ESLint and Prettier on the spec, the root build and the Storybook build pass.
- `pnpm test:ui`: 16,446 tests pass. `pnpm test:node`: 14,502 pass; its 4 failures, in `story-tree.test.ts` and the release `cache.test.mjs`, are independent of this change (#8509, #8520).
- The spec passes 2 of 2 in Chromium and 2 of 2 in WebKit; the injection runs above are in Chromium.

This branch was successfully deployed

1 active deployment
Preview — 5343ec91 Deployed Oct 27, 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. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants