Skip to content

Commit 977b336

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 (cherry picked from commit 8cf9879)
1 parent f6379dc commit 977b336

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
@@ -424,7 +424,7 @@ return $.widget( "ui.tooltip", {
424424
.addClass( "ui-tooltip-content" )
425425
.appendTo( tooltip );
426426

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

429429
return this.tooltips[ id ] = {
430430
element: element,
@@ -442,6 +442,16 @@ return $.widget( "ui.tooltip", {
442442
delete this.tooltips[ tooltip.attr( "id" ) ];
443443
},
444444

445+
_appendTo: function( target ) {
446+
var element = target.closest( ".ui-front, dialog" );
447+
448+
if ( !element.length ) {
449+
element = this.document[ 0 ].body;
450+
}
451+
452+
return element;
453+
},
454+
445455
_destroy: function() {
446456
var that = this;
447457

0 commit comments

Comments
 (0)