Skip to content

fix(modal): keep horizontal safe area in sheet modals - #31835

Open
akysil wants to merge 1 commit into
ionic-team:mainfrom
akysil:fix/31818-bug-ion-modal-sheet-toolbar-buttons-sit-
Open

akysil wants to merge 1 commit into
ionic-team:mainfrom
akysil:fix/31818-bug-ion-modal-sheet-toolbar-buttons-sit-

Conversation

@akysil

@akysil akysil commented Nov 26, 2026 •

Copy link
Copy Markdown

Issue number: resolves #31818


What is the current behavior?

A sheet modal always sets --ion-safe-area-left and --ion-safe-area-right to 0px on the ion-modal host, even when the sheet spans the full width of the viewport (phones). On a phone in landscape, the ion-toolbar inside the sheet loses its horizontal safe-area padding, so buttons in slot="start" / slot="end" sit under the notch. The values are never re-evaluated after presentation, so resizing with the sheet open doesn't fix them either.

What is the new behavior?

  • Sheet modals keep the horizontal safe-area insets (inherit) when their rendered wrapper spans the viewport width, and keep 0px when it doesn't (the centered 600px sheet on tablets, or a sheet clamped by --max-width). top stays 0px and bottom stays inherit.
  • onWindowResize() re-evaluates the horizontal insets for sheet modals, so a sheet that reaches the left/right edges after a resize picks up the insets.
  • Tests in modal/test/safe-area: full-width sheet on a landscape phone (toolbar reads the root insets), max-width-clamped sheet, and the resize case.

Approach

getInitialSafeAreaConfig() already receives the modal's covered axes, but the sheet branch ignored them. Sheets use the wrapper measurement (measureCoveredAxes()) rather than getModalCoveredAxes(), because the latter treats a modal whose --width and --height are both fullscreen values as covering the viewport without measuring, even when --max-width keeps it clear of the edges. Always inheriting the horizontal insets would pad centered sheets, and moving sheets into updateSafeAreaOverrides() would re-measure after every animation and DOM move.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Reproduction: the issue's code reproduction, or core/src/components/modal/test/safe-area with --ion-safe-area-left/right: 47px on :root and a landscape phone viewport.

Sheet modal on a landscape phone (844×390, iOS mode) with 47px left/right safe-area insets, marked by the dashed boxes, cropped to the sheet's header.

Before (main at e890307): the Close button runs into the right inset.

Sheet modal header on main: Close button under the right inset

After (this branch): the Close button ends clear of the right inset.

Sheet modal header on this branch: Close button clear of the right inset

Known limitations / follow-ups:

  • The iOS card modal branch of getInitialSafeAreaConfig() also hard-codes left/right to 0px; not changed here, since the issue only covers sheets.

Sheet modals always set --ion-safe-area-left and --ion-safe-area-right
to 0px, so toolbars inside a full-width sheet lost their notch padding
in landscape. Sheets now keep the horizontal insets when their rendered
width spans the viewport, and re-evaluate them on resize.
@akysil
akysil requested a review from a team as a code owner November 26, 2026 04:48
@akysil
akysil requested a review from thetaPC November 26, 2026 04:48
@vercel

vercel Bot commented Nov 26, 2026

Copy link
Copy Markdown

@akysil is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the package: core @ionic/core package label Nov 26, 2026

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: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ion-modal sheet toolbar buttons sit under the notch in landscape

1 participant