@@ -44,11 +44,6 @@ class TooltipStateController {
4444 this . host = host ;
4545 }
4646
47- /** @private */
48- get openedProp ( ) {
49- return this . host . manual ? 'opened' : '_autoOpened' ;
50- }
51-
5247 /** @private */
5348 get focusDelay ( ) {
5449 const tooltip = this . host ;
@@ -114,12 +109,12 @@ class TooltipStateController {
114109
115110 /** @private */
116111 _isOpened ( ) {
117- return this . host [ this . openedProp ] ;
112+ return this . host . opened ;
118113 }
119114
120115 /** @private */
121116 _setOpened ( opened ) {
122- this . host [ this . openedProp ] = opened ;
117+ this . host . opened = opened ;
123118 }
124119
125120 /** @private */
@@ -300,12 +295,15 @@ export const TooltipMixin = (superClass) =>
300295 } ,
301296
302297 /**
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.
305301 */
306302 opened : {
307303 type : Boolean ,
308304 value : false ,
305+ reflectToAttribute : true ,
306+ observer : '__openedChanged' ,
309307 sync : true ,
310308 } ,
311309
@@ -330,17 +328,6 @@ export const TooltipMixin = (superClass) =>
330328 type : String ,
331329 } ,
332330
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-
344331 /**
345332 * Element used to link with the `aria-describedby`
346333 * attribute. When not set, defaults to `target`.
@@ -432,7 +419,7 @@ export const TooltipMixin = (superClass) =>
432419 disconnectedCallback ( ) {
433420 super . disconnectedCallback ( ) ;
434421
435- if ( this . _autoOpened ) {
422+ if ( this . opened && ! this . manual ) {
436423 this . _stateController . close ( true ) ;
437424 }
438425 this . _isConnected = false ;
@@ -467,7 +454,7 @@ export const TooltipMixin = (superClass) =>
467454 }
468455
469456 /** @private */
470- __autoOpenedChanged ( opened , oldOpened ) {
457+ __openedChanged ( opened , oldOpened ) {
471458 if ( opened ) {
472459 document . addEventListener ( 'keydown' , this . __onKeyDown , true ) ;
473460 } else if ( oldOpened ) {
@@ -530,7 +517,7 @@ export const TooltipMixin = (superClass) =>
530517
531518 this . __focusInside = true ;
532519
533- if ( ! this . __isTargetHidden && ( ! this . __hoverInside || ! this . _autoOpened ) ) {
520+ if ( ! this . __isTargetHidden && ( ! this . __hoverInside || ! this . opened ) ) {
534521 this . _stateController . open ( { focus : true } ) ;
535522 }
536523 }
@@ -555,6 +542,10 @@ export const TooltipMixin = (superClass) =>
555542
556543 /** @private */
557544 __onKeyDown ( event ) {
545+ if ( this . manual ) {
546+ return ;
547+ }
548+
558549 if ( event . key === 'Escape' ) {
559550 event . stopPropagation ( ) ;
560551 this . _stateController . close ( true ) ;
@@ -587,7 +578,7 @@ export const TooltipMixin = (superClass) =>
587578
588579 this . __hoverInside = true ;
589580
590- if ( ! this . __isTargetHidden && ( ! this . __focusInside || ! this . _autoOpened ) ) {
581+ if ( ! this . __isTargetHidden && ( ! this . __focusInside || ! this . opened ) ) {
591582 this . _stateController . open ( { hover : true } ) ;
592583 }
593584 }
@@ -647,6 +638,10 @@ export const TooltipMixin = (superClass) =>
647638
648639 /** @private */
649640 __onTargetVisibilityChange ( isVisible ) {
641+ if ( this . manual ) {
642+ return ;
643+ }
644+
650645 const oldHidden = this . __isTargetHidden ;
651646 this . __isTargetHidden = ! isVisible ;
652647
@@ -657,7 +652,7 @@ export const TooltipMixin = (superClass) =>
657652 }
658653
659654 // Close the overlay when the target is no longer fully visible.
660- if ( ! isVisible && this . _autoOpened ) {
655+ if ( ! isVisible && this . opened ) {
661656 this . _stateController . close ( true ) ;
662657 }
663658 }
0 commit comments