Skip to content

Stop closed dialogs from making the page scroll - #43137

Open
samyferhat wants to merge 1 commit into
twbs:mainfrom
samyferhat:fix/dialog-closed-scroll
Open

samyferhat wants to merge 1 commit into
twbs:mainfrom
samyferhat:fix/dialog-closed-scroll

Conversation

@samyferhat

@samyferhat samyferhat commented Oct 20, 2026 •

Copy link
Copy Markdown

Description

  • Set position: fixed on .dialog:not([open]) in scss/_dialog.scss.
  • The open states do not change. Modal, non-modal, and exit animation keep the same rules.

Motivation & Context

  • .dialog sets display: flex so the exit animation works. Thus a closed dialog keeps its box.
  • The UA sets position: absolute on a closed <dialog>. A tall closed dialog adds scrollable overflow, and the page shows a scrollbar.
  • A fixed box does not add scrollable overflow to the page.
  • Checked in Chromium with a long dialog after a button. Before: the page is 2594px tall and scrolls. After: 600px, no scrollbar. The positions of the open modal and non-modal dialogs are the same as before.
  • npm run lint, npm run css-test, and npm run dist pass locally.

Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would change existing functionality)

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (using npm run lint)
  • My change introduces changes to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Live previews

Related issues

Fixes #43128

🤖 Generated with Claude Code

A closed .dialog uses display: flex for the exit animation, so it keeps its box.
The UA sets position: absolute on a closed <dialog>.
A tall closed dialog thus adds scrollable overflow, and the page shows a scrollbar.
Use position: fixed while the dialog is closed. A fixed box does not add scrollable overflow.
The open states do not change.

Fixes twbs#43128

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@samyferhat
samyferhat requested a review from a team as a code owner October 20, 2026 19:53
@julien-deramond julien-deramond added v6 v6, the main branch bug Something does not work as documented css Sass sources or compiled CSS labels Oct 20, 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

bug Something does not work as documented css Sass sources or compiled CSS v6 v6, the main branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v6: Dialogs can cause that the host page scrollbar appear visible

2 participants