Skip to content

Commit

Permalink
Autocomplete: Work around isContentEditable bug in Chrome
Browse files Browse the repository at this point in the history
Fixes #14917
Closes gh-1673
  • Loading branch information
scottgonzalez committed Feb 16, 2016
1 parent 58d8b17 commit cbceca7
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion ui/widgets/autocomplete.js
Expand Up @@ -82,7 +82,7 @@ $.widget( "ui.autocomplete", {
// Inputs are always single-line, even if inside a contentEditable element // Inputs are always single-line, even if inside a contentEditable element
// IE also treats inputs as contentEditable // IE also treats inputs as contentEditable
// All other element types are determined by whether or not they're contentEditable // All other element types are determined by whether or not they're contentEditable
this.isMultiLine = isTextarea || !isInput && this.element.prop( "isContentEditable" ); this.isMultiLine = isTextarea || !isInput && this._isContentEditable( this.element );


this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ]; this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
this.isNewMenu = true; this.isNewMenu = true;
Expand Down Expand Up @@ -614,6 +614,24 @@ $.widget( "ui.autocomplete", {
// Prevents moving cursor to beginning/end of the text field in some browsers // Prevents moving cursor to beginning/end of the text field in some browsers
event.preventDefault(); event.preventDefault();
} }
},

// Support: Chrome <=50
// We should be able to just use this.element.prop( "isContentEditable" )
// but hidden elements always report false in Chrome.
// https://code.google.com/p/chromium/issues/detail?id=313082
_isContentEditable: function( element ) {
if ( !element.length ) {
return false;
}

var editable = element.prop( "contentEditable" );

if ( editable === "inherit" ) {
return this._isContentEditable( element.parent() );
}

return editable === "true";
} }
} ); } );


Expand Down

0 comments on commit cbceca7

Please sign in to comment.