Skip to content

Commit

Permalink
Merge pull request #17013 from ckeditor/ck/17002
Browse files Browse the repository at this point in the history
Fix (ui): Balloon Editor toolbar no longer sticks out of the limiter element while scrolling. Closes #17002
  • Loading branch information
Mati365 authored Sep 2, 2024
2 parents 73b1c58 + ae7c8f0 commit bb149b0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/ckeditor5-ui/src/toolbar/block/blocktoolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,15 @@ export default class BlockToolbar extends Plugin {
}
} );

// Hide the panelView when the buttonView is disabled. `isEnabled` flag might be changed when
// user scrolls the viewport and the button is no longer visible. In such case, the panel should be hidden
// otherwise it will be displayed in the wrong place.
this.listenTo<ObservableChangeEvent<boolean>>( buttonView, 'change:isEnabled', ( evt, name, isEnabled ) => {
if ( !isEnabled && this.panelView.isVisible ) {
this._hidePanel( false );
}
} );

editor.ui.view.body.add( buttonView );

return buttonView;
Expand Down
10 changes: 10 additions & 0 deletions packages/ckeditor5-ui/tests/toolbar/block/blocktoolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,16 @@ describe( 'BlockToolbar', () => {
sinon.assert.calledOnce( focusSpy );
} );

it( 'should hide the #panelView and do not focus the editable when isEnabled became false', () => {
blockToolbar.panelView.isVisible = true;
const spy = testUtils.sinon.spy( editor.editing.view, 'focus' );

blockToolbar.buttonView.isEnabled = false;

expect( blockToolbar.panelView.isVisible ).to.be.false;
sinon.assert.notCalled( spy );
} );

it( 'should hide the #panelView and focus the editable on #execute event when panel was visible', () => {
blockToolbar.panelView.isVisible = true;
const spy = testUtils.sinon.spy( editor.editing.view, 'focus' );
Expand Down

0 comments on commit bb149b0

Please sign in to comment.