Skip to content

fix(overlay): keep the iOS toolbar area dimmed for side modals - #709

Merged
blvdmitry merged 10 commits into
mainfrom
claude/sharp-faraday-math2j
Nov 10, 2026
Merged

blvdmitry merged 10 commits into
mainfrom
claude/sharp-faraday-math2j

Conversation

@blvdmitry

@blvdmitry blvdmitry commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On iOS 26+ Safari, a dimming overlay turned the area behind the floating URL bar into a solid dark bar instead of showing the dimmed page.

Safari decides its bar colors from fixed elements touching the screen edges (WebKit LocalFrameView::fixedContainerEdges). It hit-tests each edge's midpoint and takes the first fixed ancestor of suitable size as a container. It fills the bar with that container's background color, or, if it has none, with the predominant color of a 2px strip 4–6px from the edge, sampling fixed and sticky layers only. If no fixed container is found, the bar shows the page content underneath. The Overlay backdrop lived inside the fixed overlay root, so the dimming color was sampled and painted as a solid bar.

This follows what Base UI does for its Dialog and Drawer:

  • Backdrop outside the fixed layer. The Overlay backdrop is now rendered as a sibling of the overlay root (same portal, pointer-events: none, z-index fixed, painted below the root). On iOS it switches to position: absolute (@supports (-webkit-touch-callout: none)), so it's left out of Safari's fixed-layer sample. Other browsers keep position: fixed; inset: 0.
  • Backdrop bleed. Safari renders page content under the toolbar and, once scrolled, under the status bar, outside the viewport. The iOS backdrop bleeds 50lvh past the viewport on both sides, and a layout effect lines it up with the viewport.
  • Nothing painted near the edges for side modals. The floating start/end modals sit 8px from the screen edges, so their shadow reached Safari's sample strip at roughly 0.1 alpha and became an opaque bar. Their shadow is removed on iOS (--rs-modal-floating-shadow).
  • Full-screen modal background extension. Safari tints the bars with the full-screen modal's color. On iOS the modal extends its background past the screen edges (--rs-modal-full-screen-shadow, a 50lvh spread shadow), so the bled backdrop can't show as a line between the modal and the bars.
  • Swipe opacity. Swipe updates set --rs-overlay-backdrop-opacity, which only the visible state reads. Writing opacity inline kept the backdrop at full opacity during the close transition now that it is no longer faded with the root.

Toolbar behavior with this PR:

  • Overlay, center, start and end modals: the dimmed page shows under the bottom toolbar.
  • Bottom and full-screen modals: they still tint the toolbar with the modal background, the bottom one through its .edge strip and the full-screen one by covering the edge.
  • Top bar: left to Safari's default. At scroll position 0 it shows the page background; once scrolled, it shows the dimmed content with Safari's fade. A fixed top strip forcing a dimmed top bar was tried and reverted, since Safari locks or only occasionally re-reads the top bar color.
  • Contained overlays and modals: unaffected. The backdrop matches the root inside the container and the shadows are kept.

Related Issue

None.

Screenshots / Recordings

Verify on a real iOS device. Open the stories directly through iframe.html (not inside the Storybook manager):

  • Center, start and end modals should show the dimmed page under the bottom toolbar.
  • Bottom and full-screen modals should keep the toolbar tinted with the modal background, with no line between the full-screen modal and the bars.

Notes for Reviewers

  • Deliberate differences from Base UI:
    • Base UI's absolute backdrop resolves against the top of the document, so on a scrolled page it ends up off-screen. Here it is aligned with the viewport.
    • Base UI's backdrop doesn't bleed past the viewport.
  • The side-shadow change depends on Safari's current heuristics (4px probe margin, 0.1 alpha threshold), the same kind of reliance as the existing bottom .edge strip.
  • Checked in Chromium:
    • With the iOS styles forced on, on a page scrolled 1500px with a margined, position: relative body, the backdrop spans from half a viewport above to half a viewport below the visible area, and the modal still closes.
    • The backdrop fades out smoothly on close with and without a prior touch.
  • Modal and Overlay tests pass. The full storybook browser suite passes except Image > onLoad, which loads an external Unsplash URL.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TKGZMkoaXqFb4Qs9NAuT76

Render the Overlay backdrop outside of the fixed overlay root and switch it to
absolute positioning on iOS, following the Base UI approach. iOS Safari fills
its toolbar area with the color of fixed elements attached to the bottom edge,
which turned the area behind the toolbar black for side modals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKGZMkoaXqFb4Qs9NAuT76
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Library / JS 52.82 KB (+0.11% 🔺) 1.1 s (+0.11% 🔺) 0 ms (+100% 🔺) 1.1 s
Library / CSS 24.66 KB (+0.4% 🔺) 494 ms (+0.4% 🔺) 0 ms (+100% 🔺) 494 ms
Theming / JS 7.8 KB (0%) 156 ms (0%) 126 ms (-4.68% 🔽) 282 ms
Theming with a default theme definition / JS 8.68 KB (0%) 174 ms (0%) 142 ms (-24.72% 🔽) 315 ms

Swipe updates now set the backdrop opacity through a variable read only by the
visible state. The backdrop is no longer inside the root, so an inline opacity
reset after the modal transition made it jump back to full opacity on close.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKGZMkoaXqFb4Qs9NAuT76
Safari renders page content under the status bar and the floating toolbar,
outside the viewport, so the backdrop now extends past the viewport edges on
iOS instead of stopping at them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKGZMkoaXqFb4Qs9NAuT76
Safari samples the fixed layers a few pixels away from the screen edges to
color its toolbars. The shadow of the floating side modals reached that area
and turned the toolbar into an opaque bar instead of showing the overlay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKGZMkoaXqFb4Qs9NAuT76
Render an invisible fixed strip with the overlay color at the top screen edge.
Safari uses the background color of fixed elements attached to the top edge
for its top bar, so it stays solid with the dimmed color in both scroll states
instead of showing the page background or fading the scrolled content.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKGZMkoaXqFb4Qs9NAuT76
This reverts commit afb6d92. Safari's default top bar is kept instead of the
invisible top edge strip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKGZMkoaXqFb4Qs9NAuT76
This reverts commit 6300f36. Safari's default solid toolbar is kept for side
modals instead of removing their shadow to keep the toolbar see-through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKGZMkoaXqFb4Qs9NAuT76
…nd the full-screen modal background

Restores the side modal shadow removal on iOS, so Safari keeps rendering the
dimmed overlay under its toolbar instead of an opaque bar. Full-screen modals
extend their background past the screen edges on iOS, so the overlay doesn't
show as a line between the modal and the toolbars tinted with its color.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKGZMkoaXqFb4Qs9NAuT76
- Scope the iOS backdrop and modal shadow overrides to non-contained elements
  instead of resetting them for contained ones
- Remove unused offset variable defaults on the backdrop
- Use inset shorthands and drop guards covered by the backdrop ref check
- Fix comments describing a single screen edge

No computed style changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKGZMkoaXqFb4Qs9NAuT76
@blvdmitry
blvdmitry merged commit 8f75674 into main Nov 10, 2026
11 checks passed
@blvdmitry
blvdmitry deleted the claude/sharp-faraday-math2j branch November 10, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants