@@ -13,9 +13,12 @@ export default class TooltipElement extends HTMLElement {
13
13
private showing : boolean = false ;
14
14
private cleanup ?: ( ) => void ;
15
15
private prevInnerHTML ?: string ;
16
+ private tabPressed : boolean = false ;
16
17
17
18
private onMouseEnter = this . afterDelay . bind ( this , this . show ) ;
18
- private onFocus = this . show . bind ( this ) ;
19
+ private onFocus = ( ) => {
20
+ if ( this . tabPressed ) this . show ( ) ;
21
+ } ;
19
22
private onMouseLeave = this . afterDelay . bind ( this , this . hide ) ;
20
23
private onBlur = this . hide . bind ( this ) ;
21
24
@@ -41,6 +44,7 @@ export default class TooltipElement extends HTMLElement {
41
44
}
42
45
43
46
document . addEventListener ( 'keydown' , this . onKeyDown ) ;
47
+ document . addEventListener ( 'keyup' , this . onKeyUp ) ;
44
48
document . addEventListener ( 'scroll' , this . onBlur ) ;
45
49
}
46
50
@@ -62,6 +66,7 @@ export default class TooltipElement extends HTMLElement {
62
66
}
63
67
64
68
document . removeEventListener ( 'keydown' , this . onKeyDown ) ;
69
+ document . removeEventListener ( 'keyup' , this . onKeyUp ) ;
65
70
document . removeEventListener ( 'scroll' , this . onBlur ) ;
66
71
67
72
this . disabledObserver ?. disconnect ( ) ;
@@ -81,11 +86,16 @@ export default class TooltipElement extends HTMLElement {
81
86
}
82
87
83
88
private onKeyDown = ( e : KeyboardEvent ) : void => {
89
+ if ( e . key === 'Tab' ) this . tabPressed = true ;
84
90
if ( e . key === 'Escape' ) {
85
91
this . hide ( ) ;
86
92
}
87
93
} ;
88
94
95
+ private onKeyUp = ( e : KeyboardEvent ) : void => {
96
+ if ( e . key === 'Tab' ) this . tabPressed = false ;
97
+ } ;
98
+
89
99
private show ( ) {
90
100
if ( this . disabled ) return ;
91
101
0 commit comments