Skip to content

Fix offcanvas dispose scroll reset#42711

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

Fix offcanvas dispose scroll reset#42711
Kevinjohn wants to merge 1 commit into
twbs:mainfrom
Kevinjohn:fix-offcanvas-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 offcanvas with scrolling disabled.

Motivation & Context

Showing an offcanvas with the default scroll: false hides body overflow. If dispose() is called while the offcanvas is still shown, the instance is removed but the body scroll lock is left behind.

Expected: disposing the shown offcanvas clears the scroll lock it created.
Actual: disposing the shown offcanvas leaves body.style.overflow set to hidden.

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

Related closed reports: #39910 and #36397.

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 offcanvas, body overflow remains locked:

Offcanvas before dispose fix: body overflow remains hidden

After the fix, disposing clears the body overflow lock:

Offcanvas after dispose fix: body overflow is cleared

Related issues

Related: #39910, #36397.

Checks

  • git diff --check
  • npm exec -- eslint --report-unused-disable-directives js/src/offcanvas.js js/tests/unit/offcanvas.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