@@ -44,11 +44,6 @@ class TooltipStateController {
44
44
this . host = host ;
45
45
}
46
46
47
- /** @private */
48
- get openedProp ( ) {
49
- return this . host . manual ? 'opened' : '_autoOpened' ;
50
- }
51
-
52
47
/** @private */
53
48
get focusDelay ( ) {
54
49
const tooltip = this . host ;
@@ -114,12 +109,12 @@ class TooltipStateController {
114
109
115
110
/** @private */
116
111
_isOpened ( ) {
117
- return this . host [ this . openedProp ] ;
112
+ return this . host . opened ;
118
113
}
119
114
120
115
/** @private */
121
116
_setOpened ( opened ) {
122
- this . host [ this . openedProp ] = opened ;
117
+ this . host . opened = opened ;
123
118
}
124
119
125
120
/** @private */
@@ -300,12 +295,15 @@ export const TooltipMixin = (superClass) =>
300
295
} ,
301
296
302
297
/**
303
- * When true, the tooltip is opened programmatically.
304
- * Only works if `manual` is set to `true`.
298
+ * When true, the tooltip is opened.
299
+ * In manual mode, this can be set programmatically.
300
+ * In automatic mode, this is set automatically by internal logic.
305
301
*/
306
302
opened : {
307
303
type : Boolean ,
308
304
value : false ,
305
+ reflectToAttribute : true ,
306
+ observer : '__openedChanged' ,
309
307
sync : true ,
310
308
} ,
311
309
@@ -330,17 +328,6 @@ export const TooltipMixin = (superClass) =>
330
328
type : String ,
331
329
} ,
332
330
333
- /**
334
- * Set to true when the overlay is opened using auto-added
335
- * event listeners: mouseenter and focusin (keyboard only).
336
- * @protected
337
- */
338
- _autoOpened : {
339
- type : Boolean ,
340
- observer : '__autoOpenedChanged' ,
341
- sync : true ,
342
- } ,
343
-
344
331
/**
345
332
* Element used to link with the `aria-describedby`
346
333
* attribute. When not set, defaults to `target`.
@@ -432,7 +419,7 @@ export const TooltipMixin = (superClass) =>
432
419
disconnectedCallback ( ) {
433
420
super . disconnectedCallback ( ) ;
434
421
435
- if ( this . _autoOpened ) {
422
+ if ( this . opened && ! this . manual ) {
436
423
this . _stateController . close ( true ) ;
437
424
}
438
425
this . _isConnected = false ;
@@ -467,7 +454,7 @@ export const TooltipMixin = (superClass) =>
467
454
}
468
455
469
456
/** @private */
470
- __autoOpenedChanged ( opened , oldOpened ) {
457
+ __openedChanged ( opened , oldOpened ) {
471
458
if ( opened ) {
472
459
document . addEventListener ( 'keydown' , this . __onKeyDown , true ) ;
473
460
} else if ( oldOpened ) {
@@ -530,7 +517,7 @@ export const TooltipMixin = (superClass) =>
530
517
531
518
this . __focusInside = true ;
532
519
533
- if ( ! this . __isTargetHidden && ( ! this . __hoverInside || ! this . _autoOpened ) ) {
520
+ if ( ! this . __isTargetHidden && ( ! this . __hoverInside || ! this . opened ) ) {
534
521
this . _stateController . open ( { focus : true } ) ;
535
522
}
536
523
}
@@ -555,6 +542,10 @@ export const TooltipMixin = (superClass) =>
555
542
556
543
/** @private */
557
544
__onKeyDown ( event ) {
545
+ if ( this . manual ) {
546
+ return ;
547
+ }
548
+
558
549
if ( event . key === 'Escape' ) {
559
550
event . stopPropagation ( ) ;
560
551
this . _stateController . close ( true ) ;
@@ -587,7 +578,7 @@ export const TooltipMixin = (superClass) =>
587
578
588
579
this . __hoverInside = true ;
589
580
590
- if ( ! this . __isTargetHidden && ( ! this . __focusInside || ! this . _autoOpened ) ) {
581
+ if ( ! this . __isTargetHidden && ( ! this . __focusInside || ! this . opened ) ) {
591
582
this . _stateController . open ( { hover : true } ) ;
592
583
}
593
584
}
@@ -647,6 +638,10 @@ export const TooltipMixin = (superClass) =>
647
638
648
639
/** @private */
649
640
__onTargetVisibilityChange ( isVisible ) {
641
+ if ( this . manual ) {
642
+ return ;
643
+ }
644
+
650
645
const oldHidden = this . __isTargetHidden ;
651
646
this . __isTargetHidden = ! isVisible ;
652
647
@@ -657,7 +652,7 @@ export const TooltipMixin = (superClass) =>
657
652
}
658
653
659
654
// Close the overlay when the target is no longer fully visible.
660
- if ( ! isVisible && this . _autoOpened ) {
655
+ if ( ! isVisible && this . opened ) {
661
656
this . _stateController . close ( true ) ;
662
657
}
663
658
}
0 commit comments