Skip to content

Commit

Permalink
Tooltip: Follow the standard appendTo logic
Browse files Browse the repository at this point in the history
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 26, 2015
1 parent 899d907 commit 8cf9879
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ui/tooltip.js
Expand Up @@ -428,7 +428,7 @@ $.widget( "ui.tooltip", {
this._addClass( content, "ui-tooltip-content" ); this._addClass( content, "ui-tooltip-content" );
this._addClass( tooltip, "ui-tooltip", "ui-widget ui-widget-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 ] = { return this.tooltips[ id ] = {
element: element, element: element,
Expand All @@ -446,6 +446,16 @@ $.widget( "ui.tooltip", {
delete this.tooltips[ tooltip.attr( "id" ) ]; 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() { _destroy: function() {
var that = this; var that = this;


Expand Down

1 comment on commit 8cf9879

@rejetto
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.