Skip to content

Commit

Permalink
Hide tooltip without delay for instant tooltips.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dumluregn committed Oct 18, 2024
1 parent edea934 commit f9c7020
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/ckeditor5-ui/src/tooltipmanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,14 @@ export default class TooltipManager extends /* #__PURE__ */ DomEmitterMixin() {
if ( isLeavingBalloon || ( descendantWithTooltip && descendantWithTooltip !== relatedDescendantWithTooltip ) ) {
this._pinTooltipDebounced.cancel();

// If the currently visible tooltip is instant, unpin it immediately.
if (
this._currentElementWithTooltip && this._currentElementWithTooltip.matches( '[data-cke-tooltip-instant]' ) ||
descendantWithTooltip && descendantWithTooltip.matches( '[data-cke-tooltip-instant]' )
) {
this._unpinTooltip();
}

this._unpinTooltipDebounced();
}
} else {
Expand Down
13 changes: 13 additions & 0 deletions packages/ckeditor5-ui/tests/tooltip/tooltipmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,19 @@ describe( 'TooltipManager', () => {
sinon.assert.calledOnce( unpinSpy );
} );

it( 'should remove the tooltip immediately if the element has `data-cke-tooltip-instant` attribute', () => {
elements.a.dataset.ckeTooltipInstant = true;

utils.dispatchMouseEnter( elements.a );

sinon.assert.calledOnce( pinSpy );

unpinSpy = sinon.spy( tooltipManager.balloonPanelView, 'unpin' );
utils.dispatchMouseLeave( tooltipManager.balloonPanelView.element, elements.b );

sinon.assert.calledOnce( unpinSpy );
} );

it( 'should not work if the tooltip is currently pinned and the event target is different than the current element', () => {
utils.dispatchMouseEnter( elements.a );
utils.waitForTheTooltipToShow( clock );
Expand Down

0 comments on commit f9c7020

Please sign in to comment.