From 0e3e024cb23a3981e3fa2d37822a591c632acc45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 16 Feb 2016 10:22:45 -0500 Subject: [PATCH 1/2] Autocomplete: Work around `isContentEditable` bug in Chrome Fixes #14917 --- ui/widgets/autocomplete.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ui/widgets/autocomplete.js b/ui/widgets/autocomplete.js index 060d8e94f8b..cbf57df712f 100644 --- a/ui/widgets/autocomplete.js +++ b/ui/widgets/autocomplete.js @@ -82,7 +82,7 @@ $.widget( "ui.autocomplete", { // Inputs are always single-line, even if inside a contentEditable element // IE also treats inputs as 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.isNewMenu = true; @@ -614,6 +614,22 @@ $.widget( "ui.autocomplete", { // Prevents moving cursor to beginning/end of the text field in some browsers 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" ); + + return editable === "true" ? true : + editable === "false" ? false : + this._isContentEditable( element.parent() ); } } ); From 99156b7e66ab8f37fad94fde417585be3d7266f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 16 Feb 2016 12:16:14 -0500 Subject: [PATCH 2/2] fixup: Traverse first --- ui/widgets/autocomplete.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/widgets/autocomplete.js b/ui/widgets/autocomplete.js index cbf57df712f..079b0dab07b 100644 --- a/ui/widgets/autocomplete.js +++ b/ui/widgets/autocomplete.js @@ -627,9 +627,11 @@ $.widget( "ui.autocomplete", { var editable = element.prop( "contentEditable" ); - return editable === "true" ? true : - editable === "false" ? false : - this._isContentEditable( element.parent() ); + if ( editable === "inherit" ) { + return this._isContentEditable( element.parent() ); + } + + return editable === "true"; } } );