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
This commit is contained in:
@@ -91,6 +91,7 @@
|
|||||||
_handleRemove: function(e) {
|
_handleRemove: function(e) {
|
||||||
var toRemove = e.detail.account;
|
var toRemove = e.detail.account;
|
||||||
this._removeAccount(toRemove);
|
this._removeAccount(toRemove);
|
||||||
|
this.$.entry.focus();
|
||||||
},
|
},
|
||||||
|
|
||||||
_removeAccount: function(toRemove) {
|
_removeAccount: function(toRemove) {
|
||||||
@@ -105,7 +106,6 @@
|
|||||||
}
|
}
|
||||||
if (matches) {
|
if (matches) {
|
||||||
this.splice('accounts', i, 1);
|
this.splice('accounts', i, 1);
|
||||||
this.$.entry.focus();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -73,6 +73,7 @@ limitations under the License.
|
|||||||
id="cursor"
|
id="cursor"
|
||||||
index="{{_index}}"
|
index="{{_index}}"
|
||||||
cursor-target-class="selected"
|
cursor-target-class="selected"
|
||||||
|
scroll-behavior="keep-visible"
|
||||||
stops="[[_getSuggestionElems(_suggestions)]]"></gr-cursor-manager>
|
stops="[[_getSuggestionElems(_suggestions)]]"></gr-cursor-manager>
|
||||||
</template>
|
</template>
|
||||||
<script src="gr-autocomplete.js"></script>
|
<script src="gr-autocomplete.js"></script>
|
||||||
|
@@ -199,6 +199,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_handleInputKeydown: function(e) {
|
_handleInputKeydown: function(e) {
|
||||||
|
this._focused = true;
|
||||||
switch (e.keyCode) {
|
switch (e.keyCode) {
|
||||||
case 38: // Up
|
case 38: // Up
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
Reference in New Issue
Block a user