Merge "Fix the focus for gr-autocomplete in polymer 2"
diff --git a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.html b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.html
index 46877d7..1fa3db1 100644
--- a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.html
+++ b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.html
@@ -77,30 +77,13 @@
on-blur="_onInputBlur"
autocomplete="off">
- <template is="dom-if" if="[[_isPolymer2()]]">
- <!-- Content uses vertical-align:baseline. If iron-icon is placed
- directly in the slot and is not visible, vertical-align doesn't
- work, because display:none convert it from inline-block element to
- block element. To fix this problem, iron-icon is wrapped in div
- which never changes display type.
- The problem doesn't exist in Polymer1 because DOM is different.
- Applying the same fix to Polymer1 breaks vertical-align.
- -->
- <div slot="prefix">
- <iron-icon
- icon="gr-icons:search"
- class$="searchIcon [[_computeShowSearchIconClass(showSearchIcon)]]">
- </iron-icon>
- </div>
- </template>
- <template is="dom-if" if="[[!_isPolymer2()]]">
+ <!-- prefix as attribute is required to for polymer 1 -->
+ <div slot="prefix" prefix>
<iron-icon
- prefix
icon="gr-icons:search"
class$="searchIcon [[_computeShowSearchIconClass(showSearchIcon)]]">
</iron-icon>
- </template>
-
+ </div>
</paper-input>
<gr-autocomplete-dropdown
vertical-align="top"
diff --git a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.js b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.js
index 745cff1..d422df8 100644
--- a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.js
+++ b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.js
@@ -196,7 +196,7 @@
},
focus() {
- this.$.input.focus();
+ this._nativeInput.focus();
},
selectAll() {
@@ -330,7 +330,7 @@
default:
// For any normal keypress, return focus to the input to allow for
// unbroken user input.
- this.$.input.inputElement.focus();
+ this.focus();
// Since this has been a normal keypress, the suggestions will have
// been based on a previous input. Clear them. This prevents an
@@ -430,9 +430,5 @@
_computeShowSearchIconClass(showSearchIcon) {
return showSearchIcon ? 'showSearchIcon' : '';
},
-
- _isPolymer2() {
- return window.POLYMER2;
- },
});
})();