Permalink
Browse files

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
  • Loading branch information...
scottgonzalez committed Mar 23, 2015
1 parent 899d907 commit 8cf98798a58afb7197bce0d6ca1c5b658ae04011
Showing with 11 additions and 1 deletion.
  1. +11 −1 ui/tooltip.js
View
@@ -428,7 +428,7 @@ $.widget( "ui.tooltip", {
this._addClass( content, "ui-tooltip-content" );
this._addClass( tooltip, "ui-tooltip", "ui-widget ui-widget-content" );
- tooltip.appendTo( this.document[ 0 ].body );
+ tooltip.appendTo( this._appendTo( element ) );
return this.tooltips[ id ] = {
element: element,
@@ -446,6 +446,16 @@ $.widget( "ui.tooltip", {
delete this.tooltips[ tooltip.attr( "id" ) ];
},
+ _appendTo: function( target ) {
+ var element = target.closest( ".ui-front, dialog" );
+
+ if ( !element.length ) {
+ element = this.document[ 0 ].body;
+ }
+
+ return element;
+ },
+
_destroy: function() {
var that = this;

1 comment on commit 8cf9879

@rejetto

This comment has been minimized.

Show comment
Hide comment
@rejetto

rejetto Jul 20, 2017

This is leading to suboptimal layouting in my case.
image

This wasn't happening with previous version.
Apparently the right boundary is "softly" limited to the dialog. I say softly because it goes beyond if the text is unbreakable. I guess this is the browser's logic (Chrome 59), probably generally good, but not in my case.
I will workaround it by wrapping the content in a PRE tag, but i wanted to let you know.

This is leading to suboptimal layouting in my case.
image

This wasn't happening with previous version.
Apparently the right boundary is "softly" limited to the dialog. I say softly because it goes beyond if the text is unbreakable. I guess this is the browser's logic (Chrome 59), probably generally good, but not in my case.
I will workaround it by wrapping the content in a PRE tag, but i wanted to let you know.

Please sign in to comment.