Skip to content

Fix modal dispose scroll reset#42712

Draft
Kevinjohn wants to merge 1 commit into
twbs:mainfrom
Kevinjohn:fix-modal-dispose-scroll-lock
Draft

Fix modal dispose scroll reset#42712
Kevinjohn wants to merge 1 commit into
twbs:mainfrom
Kevinjohn:fix-modal-dispose-scroll-lock

Conversation

@Kevinjohn

@Kevinjohn Kevinjohn commented Jul 20, 2026

Copy link
Copy Markdown

Description

Resets the body scrollbar state when disposing a shown modal.

Motivation & Context

Showing a modal adds modal-open to the body and hides body overflow. If dispose() is called while the modal is still shown, the instance is removed but the body scroll lock is left behind.

Expected: disposing the shown modal clears the scroll lock it created.
Actual: disposing the shown modal leaves modal-open on the body and keeps body.style.overflow set to hidden.

This mirrors the normal hide cleanup for the dispose path and adds unit coverage for disposing a shown modal.

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
  • 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

Actual screenshots

Before disposing the shown modal, the body remains scroll-locked:

Modal before dispose fix: modal-open remains true and body overflow remains hidden

After the fix, disposing clears modal-open and body overflow:

Modal after dispose fix: modal-open is false and body overflow is cleared

Related issues

None.

Checks

  • git diff --check
  • npm exec -- eslint --report-unused-disable-directives js/src/modal.js js/tests/unit/modal.spec.js
  • npm run js-test-karma

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants