Skip to content

Commit edea934

Browse files
committed
Change the matcher for instant tooltips from class to attribute.
1 parent f9f0850 commit edea934

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

packages/ckeditor5-ui/src/tooltipmanager.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,21 @@ const BALLOON_CLASS = 'ck-tooltip';
5656
*
5757
* # Disabling tooltips
5858
*
59-
* In order to disable the tooltip temporarily, use the `data-cke-tooltip-disabled` attribute:
59+
* In order to disable the tooltip temporarily, use the `data-cke-tooltip-disabled` attribute:
6060
*
6161
* ```ts
6262
* domElement.dataset.ckeTooltipText = 'Disabled. For now.';
6363
* domElement.dataset.ckeTooltipDisabled = 'true';
6464
* ```
6565
*
66+
* # Instant tooltips
67+
*
68+
* To remove the delay before showing or hiding the tooltip, use the `data-cke-tooltip-instant` attribute:
69+
*
70+
* ```ts
71+
* domElement.dataset.ckeTooltipInstant = 'true';
72+
* ```
73+
*
6674
* # Styling tooltips
6775
*
6876
* By default, the tooltip has `.ck-tooltip` class and its text inner `.ck-tooltip__text`.
@@ -304,12 +312,12 @@ export default class TooltipManager extends /* #__PURE__ */ DomEmitterMixin() {
304312
// The tooltip should be pinned immediately when the element gets focused using keyboard.
305313
// If it is focused using the mouse, the tooltip should be pinned after a delay to prevent flashing.
306314
// See https://github.com/ckeditor/ckeditor5/issues/16383
307-
// Also, if the element has a class `ck-with-instant-tooltip`, the tooltip should be pinned immediately.
315+
// Also, if the element has an attribute `data-cke-tooltip-instant`, the tooltip should be pinned immediately.
308316
// This is useful for elements that have their content partially hidden (e.g. a long text in a small container)
309317
// and should show a tooltip on hover, like merge field.
310-
if (
318+
if (
311319
evt.name === 'focus' && !elementWithTooltipAttribute.matches( ':hover' ) ||
312-
elementWithTooltipAttribute.matches( '.ck-with-instant-tooltip' )
320+
elementWithTooltipAttribute.matches( '[data-cke-tooltip-instant]' )
313321
) {
314322
this._pinTooltip( elementWithTooltipAttribute, getTooltipData( elementWithTooltipAttribute ) );
315323
} else {
@@ -337,6 +345,7 @@ export default class TooltipManager extends /* #__PURE__ */ DomEmitterMixin() {
337345
// Do not hide the tooltip when the user moves the cursor over it.
338346
if ( isEnteringBalloon ) {
339347
this._unpinTooltipDebounced.cancel();
348+
340349
return;
341350
}
342351

packages/ckeditor5-ui/tests/tooltip/tooltipmanager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ describe( 'TooltipManager', () => {
306306
} );
307307
} );
308308

309-
it( 'should pin a tooltip instantly if element has a `ck-with-instant-tooltip` class', () => {
310-
elements.a.classList.add( 'ck-with-instant-tooltip' );
309+
it( 'should pin a tooltip instantly if element has a `data-cke-tooltip-instant` attribute', () => {
310+
elements.a.dataset.ckeTooltipInstant = true;
311311

312312
utils.dispatchMouseEnter( elements.a );
313313

0 commit comments

Comments
 (0)