Skip to content

Image: Fit the lightbox overlay to the visible screen on iOS Safari - #84739

Open
Adi-ty wants to merge 4 commits into
WordPress:trunkfrom
Adi-ty:fix/image-lightbox-ios-safari-viewport
Open

Adi-ty wants to merge 4 commits into
WordPress:trunkfrom
Adi-ty:fix/image-lightbox-ios-safari-viewport

Conversation

@Adi-ty

@Adi-ty Adi-ty commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What?

Part of #84699

Sizes the image lightbox overlay to the area the browser actually lays fixed content out in, instead of hardcoding 100vh. On iOS Safari that area is shorter than 100vh, so the overlay used to overflow the visible screen. Also measures the overlay in view.js so the zoom still starts from the thumbnail.

Why?

On iOS Safari the lightbox had two visible problems, both from one root cause — .wp-lightbox-overlay was height: 100vh, taller than the area Safari lays fixed content out in:

  • The overlay didn't cover the whole visible screen, so page content poked through near the browser chrome (post title at the top, a strip at the bottom).
  • The enlarged image wasn't vertically centered — it sat low, because the image containers center with top: 50% inside a box that ran past the screen bottom.

How?

  • .wp-lightbox-overlay uses inset: 0 instead of width: 100%; height: 100vh, so it matches the area the browser lays fixed content out in, and the image containers' top: 50% centers on the visible screen.
  • setOverlayStyles() in view.js measures the overlay and sizes the image against its height instead of window.innerHeight. It passes the height to CSS as --wp--lightbox-overlay-height, which replaces -50vh in the zoom keyframes so the zoom still starts from the thumbnail.
  • A new e2e test insets the overlay to stand in for Safari's shorter fixed area, since Chromium can't reproduce the toolbars. It checks that the zoom starts on the thumbnail, that the overlay is inset to that area instead of staying 100vh, and that the image is centered.

Testing Instructions

  1. Create a post with a Gallery block and enable "Expand on click".
  2. View the post in Safari on an iPhone (iOS 26) and tap an image to open the lightbox.
  3. Check that no page content shows behind the status bar or the browser toolbars, that the image is vertically centered on the visible screen, and that the previous/next buttons are visible.
  4. On desktop, check that the lightbox opens, zooms, navigates and closes as before.

Testing Instructions for Keyboard

  1. Tab to an image's "Enlarge" button and press Enter to open the lightbox.
  2. Use the Left and Right arrow keys to move between gallery images, and Tab to move between the lightbox buttons.
  3. Press Escape to close the lightbox.

Screenshots or screencast

Before After
Lightbox on trunk: page shows behind the Safari bars, image sits off-center Lightbox with fix: backdrop covers the Safari bars, image centered

Use of AI Tools

Assisted by Claude Code, all changes tested & reviewed manually.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Adi-ty <iamadisingh@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Oct 14, 2026
@Adi-ty
Adi-ty marked this pull request as ready for review October 15, 2026 05:03
@Adi-ty
Adi-ty requested a review from fabiankaegy as a code owner October 15, 2026 05:03

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block library /packages/block-library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant