Skip to content

Commit cbceca7

Browse files
committed
Autocomplete: Work around isContentEditable bug in Chrome
Fixes #14917 Closes gh-1673
1 parent 58d8b17 commit cbceca7

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

ui/widgets/autocomplete.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ $.widget( "ui.autocomplete", {
8282
// Inputs are always single-line, even if inside a contentEditable element
8383
// IE also treats inputs as contentEditable
8484
// All other element types are determined by whether or not they're contentEditable
85-
this.isMultiLine = isTextarea || !isInput && this.element.prop( "isContentEditable" );
85+
this.isMultiLine = isTextarea || !isInput && this._isContentEditable( this.element );
8686

8787
this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
8888
this.isNewMenu = true;
@@ -614,6 +614,24 @@ $.widget( "ui.autocomplete", {
614614
// Prevents moving cursor to beginning/end of the text field in some browsers
615615
event.preventDefault();
616616
}
617+
},
618+
619+
// Support: Chrome <=50
620+
// We should be able to just use this.element.prop( "isContentEditable" )
621+
// but hidden elements always report false in Chrome.
622+
// https://code.google.com/p/chromium/issues/detail?id=313082
623+
_isContentEditable: function( element ) {
624+
if ( !element.length ) {
625+
return false;
626+
}
627+
628+
var editable = element.prop( "contentEditable" );
629+
630+
if ( editable === "inherit" ) {
631+
return this._isContentEditable( element.parent() );
632+
}
633+
634+
return editable === "true";
617635
}
618636
} );
619637

0 commit comments

Comments
 (0)