mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-10-05 01:44:18 +00:00
Tooltip: Don't close tooltips on mouseleave if the element is still focused.
This commit is contained in:
parent
ade1fe1887
commit
133fba2ad9
@ -47,4 +47,30 @@ test( "focus events", function() {
|
|||||||
element.trigger( "blur" );
|
element.trigger( "blur" );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test( "mixed events", function() {
|
||||||
|
expect( 2 );
|
||||||
|
var element = $( "#tooltipped1" ).tooltip();
|
||||||
|
|
||||||
|
element.one( "tooltipopen", function( event ) {
|
||||||
|
same( event.originalEvent.type, "focusin" );
|
||||||
|
});
|
||||||
|
element[0].focus();
|
||||||
|
|
||||||
|
element.one( "tooltipopen", function() {
|
||||||
|
ok( false, "open triggered while already open" );
|
||||||
|
});
|
||||||
|
element.trigger( "mouseover" );
|
||||||
|
|
||||||
|
element.bind( "tooltipclose", function( event ) {
|
||||||
|
ok( false, "close triggered while still focused" );
|
||||||
|
});
|
||||||
|
element.trigger( "mouseleave" );
|
||||||
|
element.unbind( "tooltipclose" );
|
||||||
|
|
||||||
|
element.one( "tooltipclose", function( event ) {
|
||||||
|
same( event.originalEvent.type, "blur" );
|
||||||
|
});
|
||||||
|
element[0].blur();
|
||||||
|
});
|
||||||
|
|
||||||
}( jQuery ) );
|
}( jQuery ) );
|
||||||
|
7
ui/jquery.ui.tooltip.js
vendored
7
ui/jquery.ui.tooltip.js
vendored
@ -56,7 +56,8 @@ $.widget( "ui.tooltip", {
|
|||||||
target = $( event ? event.target : this.element )
|
target = $( event ? event.target : this.element )
|
||||||
.closest( this.options.items );
|
.closest( this.options.items );
|
||||||
|
|
||||||
if ( !target.length ) {
|
// if aria-describedby exists, then the tooltip is already open
|
||||||
|
if ( !target.length || target.attr( "aria-describedby" ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +132,9 @@ $.widget( "ui.tooltip", {
|
|||||||
target.attr( "title", target.data( "tooltip-title" ) );
|
target.attr( "title", target.data( "tooltip-title" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( this.options.disabled ) {
|
// don't close if the element has focus
|
||||||
|
// this prevents the tooltip from closing if you hover while focused
|
||||||
|
if ( this.options.disabled || document.activeElement === target[0] ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user