Skip to content

Commit 7c46b78

Browse files
committed
Tooltip: Reposition tracking tooltips when they gain focus.
1 parent 556497f commit 7c46b78

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

ui/jquery.ui.tooltip.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,19 @@ $.widget( "ui.tooltip", {
118118
target = $( event ? event.target : this.element )
119119
.closest( this.options.items );
120120

121-
// if ui-tooltip-id exists, then the tooltip is already open
122-
if ( !target.length || target.data( "ui-tooltip-id" ) ) {
121+
// No element to show a tooltip for
122+
if ( !target.length ) {
123+
return;
124+
}
125+
126+
// If the tooltip is open and we're tracking then reposition the tooltip.
127+
// This makes sure that a tracking tooltip doesn't obscure a focused element
128+
// if the user was hovering when the element gained focused.
129+
if ( this.options.track && target.data( "ui-tooltip-id" ) ) {
130+
this._find( target ).position( $.extend({
131+
of: target
132+
}, this.options.position ) );
133+
// TODO: Do we need to unbind the mousemove handler here?
123134
return;
124135
}
125136

@@ -251,7 +262,7 @@ $.widget( "ui.tooltip", {
251262
target.removeData( "tooltip-open" );
252263
target.unbind( "mouseleave.tooltip focusout.tooltip keyup.tooltip" );
253264

254-
// TODO use _off
265+
// TODO use _off (see associated TODO in open())
255266
this.document.unbind( "mousemove.tooltip" );
256267

257268
this.closing = true;

0 commit comments

Comments
 (0)