File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -47,4 +47,30 @@ test( "focus events", function() {
47
47
element . trigger ( "blur" ) ;
48
48
} ) ;
49
49
50
+ test ( "mixed events" , function ( ) {
51
+ expect ( 2 ) ;
52
+ var element = $ ( "#tooltipped1" ) . tooltip ( ) ;
53
+
54
+ element . one ( "tooltipopen" , function ( event ) {
55
+ same ( event . originalEvent . type , "focusin" ) ;
56
+ } ) ;
57
+ element [ 0 ] . focus ( ) ;
58
+
59
+ element . one ( "tooltipopen" , function ( ) {
60
+ ok ( false , "open triggered while already open" ) ;
61
+ } ) ;
62
+ element . trigger ( "mouseover" ) ;
63
+
64
+ element . bind ( "tooltipclose" , function ( event ) {
65
+ ok ( false , "close triggered while still focused" ) ;
66
+ } ) ;
67
+ element . trigger ( "mouseleave" ) ;
68
+ element . unbind ( "tooltipclose" ) ;
69
+
70
+ element . one ( "tooltipclose" , function ( event ) {
71
+ same ( event . originalEvent . type , "blur" ) ;
72
+ } ) ;
73
+ element [ 0 ] . blur ( ) ;
74
+ } ) ;
75
+
50
76
} ( jQuery ) ) ;
Original file line number Diff line number Diff line change @@ -56,7 +56,8 @@ $.widget( "ui.tooltip", {
56
56
target = $ ( event ? event . target : this . element )
57
57
. closest ( this . options . items ) ;
58
58
59
- if ( ! target . length ) {
59
+ // if aria-describedby exists, then the tooltip is already open
60
+ if ( ! target . length || target . attr ( "aria-describedby" ) ) {
60
61
return ;
61
62
}
62
63
@@ -131,7 +132,9 @@ $.widget( "ui.tooltip", {
131
132
target . attr ( "title" , target . data ( "tooltip-title" ) ) ;
132
133
}
133
134
134
- if ( this . options . disabled ) {
135
+ // don't close if the element has focus
136
+ // this prevents the tooltip from closing if you hover while focused
137
+ if ( this . options . disabled || document . activeElement === target [ 0 ] ) {
135
138
return ;
136
139
}
137
140
You can’t perform that action at this time.
0 commit comments