Skip to content

Commit d740e45

Browse files
committed
Tooltip: Reposition tracking tooltips when they gain focus.
1 parent 5c2cf39 commit d740e45

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

ui/jquery.ui.tooltip.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,18 @@ $.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 ) );
123133
return;
124134
}
125135

@@ -250,9 +260,7 @@ $.widget( "ui.tooltip", {
250260

251261
target.removeData( "tooltip-open" );
252262
this._off( target, "mouseleave focusout keyup" );
253-
254-
// TODO use _off
255-
this.document.unbind( "mousemove.tooltip" );
263+
this._off( this.document, "mousemove" );
256264

257265
this.closing = true;
258266
this._trigger( "close", event, { tooltip: tooltip } );

0 commit comments

Comments
 (0)