Skip to content

Commit 8cf9879

Browse files
committed
Tooltip: Follow the standard appendTo logic
Even though there's no reason to ever configure the parent element via an `appendTo` option, following the standard logic is useful for scrollable elements and native dialogs. Fixes #10739 Closes gh-1517
1 parent 899d907 commit 8cf9879

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

ui/tooltip.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ $.widget( "ui.tooltip", {
428428
this._addClass( content, "ui-tooltip-content" );
429429
this._addClass( tooltip, "ui-tooltip", "ui-widget ui-widget-content" );
430430

431-
tooltip.appendTo( this.document[ 0 ].body );
431+
tooltip.appendTo( this._appendTo( element ) );
432432

433433
return this.tooltips[ id ] = {
434434
element: element,
@@ -446,6 +446,16 @@ $.widget( "ui.tooltip", {
446446
delete this.tooltips[ tooltip.attr( "id" ) ];
447447
},
448448

449+
_appendTo: function( target ) {
450+
var element = target.closest( ".ui-front, dialog" );
451+
452+
if ( !element.length ) {
453+
element = this.document[ 0 ].body;
454+
}
455+
456+
return element;
457+
},
458+
449459
_destroy: function() {
450460
var that = this;
451461

0 commit comments

Comments
 (0)