From 75154e3237804064e8c50e21c8a61bfeac33a9a9 Mon Sep 17 00:00:00 2001 From: Kasper Nilsson Date: Wed, 23 Nov 2016 14:25:39 -0800 Subject: [PATCH] Fix focus issue with autocomplete Due to asynchronous event handling, sometimes the _focused flag is not properly set to 'true' even when the input is focused. With this change, the _focused flag is set to true on keydown in the input. Also sets a parameter on the cursor-manager for better UX. Bug: Issue 4950 Change-Id: Ib53942f0d1ff86351bdbd33770696e1bb3e029ca --- .../app/elements/change/gr-account-list/gr-account-list.js | 2 +- .../app/elements/shared/gr-autocomplete/gr-autocomplete.html | 1 + .../app/elements/shared/gr-autocomplete/gr-autocomplete.js | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/polygerrit-ui/app/elements/change/gr-account-list/gr-account-list.js b/polygerrit-ui/app/elements/change/gr-account-list/gr-account-list.js index 30665896c2..3b1775650f 100644 --- a/polygerrit-ui/app/elements/change/gr-account-list/gr-account-list.js +++ b/polygerrit-ui/app/elements/change/gr-account-list/gr-account-list.js @@ -91,6 +91,7 @@ _handleRemove: function(e) { var toRemove = e.detail.account; this._removeAccount(toRemove); + this.$.entry.focus(); }, _removeAccount: function(toRemove) { @@ -105,7 +106,6 @@ } if (matches) { this.splice('accounts', i, 1); - this.$.entry.focus(); return; } } 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 5de54bbd91..d7017ca7f6 100644 --- a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.html +++ b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.html @@ -73,6 +73,7 @@ limitations under the License. id="cursor" index="{{_index}}" cursor-target-class="selected" + scroll-behavior="keep-visible" stops="[[_getSuggestionElems(_suggestions)]]"> 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 0626288be0..863b85a941 100644 --- a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.js +++ b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.js @@ -199,6 +199,7 @@ }, _handleInputKeydown: function(e) { + this._focused = true; switch (e.keyCode) { case 38: // Up e.preventDefault();