File tree Expand file tree Collapse file tree 2 files changed +27
-5
lines changed
packages/rich-text-editor Expand file tree Collapse file tree 2 files changed +27
-5
lines changed Original file line number Diff line number Diff line change 99 * license.
1010 */
1111import '../vendor/vaadin-quill.js' ;
12+ import { isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js' ;
1213import { timeOut } from '@vaadin/component-base/src/async.js' ;
1314import { Debouncer } from '@vaadin/component-base/src/debounce.js' ;
1415import { I18nMixin } from '@vaadin/component-base/src/i18n-mixin.js' ;
@@ -425,13 +426,16 @@ export const RichTextEditorMixin = (superClass) =>
425426 }
426427
427428 /** @private */
428- __showTooltip ( event ) {
429- const target = event . target ;
429+ __showTooltip ( { type, target } ) {
430+ // Only show tooltip when focused with keyboard
431+ if ( type === 'focusin' && ! isKeyboardActive ( ) ) {
432+ return ;
433+ }
430434 this . _tooltip . target = target ;
431435 this . _tooltip . text = target . ariaLabel ;
432436 this . _tooltip . _stateController . open ( {
433- focus : event . type === 'focusin' ,
434- hover : event . type === 'mouseenter' ,
437+ focus : type === 'focusin' ,
438+ hover : type === 'mouseenter' ,
435439 } ) ;
436440 }
437441
Original file line number Diff line number Diff line change 77 focusout ,
88 isDesktopSafari ,
99 isFirefox ,
10+ mousedown ,
1011 nextRender ,
1112 nextUpdate ,
1213 oneEvent ,
@@ -640,7 +641,10 @@ describe('toolbar controls', () => {
640641 expect ( overlay . opened ) . to . be . false ;
641642 } ) ;
642643
643- it ( 'should open tooltip when focusing toolbar button' , ( ) => {
644+ it ( 'should open tooltip when focusing toolbar button with keyboard' , ( ) => {
645+ // Mimic keyboard focus
646+ esc ( rte ) ;
647+
644648 const undo = getButton ( 'undo' ) ;
645649 undo . focus ( ) ;
646650
@@ -649,7 +653,18 @@ describe('toolbar controls', () => {
649653 expect ( overlay . opened ) . to . be . true ;
650654 } ) ;
651655
656+ it ( 'should not open tooltip when focusing toolbar button with mouse' , ( ) => {
657+ const undo = getButton ( 'undo' ) ;
658+ mousedown ( undo ) ;
659+ undo . focus ( ) ;
660+
661+ expect ( overlay . opened ) . to . be . false ;
662+ } ) ;
663+
652664 it ( 'should move tooltip when focusing other toolbar button' , ( ) => {
665+ // Mimic keyboard focus
666+ esc ( rte ) ;
667+
653668 const undo = getButton ( 'undo' ) ;
654669 undo . focus ( ) ;
655670
@@ -662,6 +677,9 @@ describe('toolbar controls', () => {
662677 } ) ;
663678
664679 it ( 'should close tooltip when focus is moved away from toolbar button' , ( ) => {
680+ // Mimic keyboard focus
681+ esc ( rte ) ;
682+
665683 const undo = getButton ( 'undo' ) ;
666684 undo . focus ( ) ;
667685
You can’t perform that action at this time.
0 commit comments