Skip to content

Commit

Permalink
Add a condition for reenabling the page scroll.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dumluregn committed Dec 19, 2024
1 parent 2b2923a commit 63a06a8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/ckeditor5-ui/src/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ export default class Dialog extends Plugin {
public override destroy(): void {
super.destroy();

this._unlockBodyScroll();
if ( Dialog._visibleDialogPlugin === this ) {
this._unlockBodyScroll();
}
}

/**
Expand Down
18 changes: 18 additions & 0 deletions packages/ckeditor5-ui/tests/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,24 @@ describe( 'Dialog', () => {

expect( document.documentElement.classList.contains( 'ck-dialog-scroll-locked' ) ).to.be.false;
} );

it( 'should not unlock scrolling on the document if modal was displayed by another plugin instance', () => {
const tempDialogPlugin = new Dialog( editor );

tempDialogPlugin._show( {
position: DialogViewPosition.EDITOR_CENTER,
isModal: true,
className: 'foo'
} );

expect( document.documentElement.classList.contains( 'ck-dialog-scroll-locked' ) ).to.be.true;

dialogPlugin.destroy();

expect( document.documentElement.classList.contains( 'ck-dialog-scroll-locked' ) ).to.be.true;

tempDialogPlugin.destroy();
} );
} );

describe( 'show()', () => {
Expand Down

0 comments on commit 63a06a8

Please sign in to comment.