When navigating up in the autocomplete search result list the cursor usually reset back to the start of the input. Now we get the element and use focus and setSelectionRange to move the cursor back to the end at the very next frame.

This commit is contained in:
2019-10-30 21:55:39 +01:00
parent d7e4d2095c
commit 70a6ed189b

View File

@@ -3,6 +3,7 @@
<div class="search">
<input
ref="input"
type="text"
placeholder="Search for a movie or show"
autocorrect="off"
@@ -93,6 +94,13 @@ export default {
navigateUp() {
this.focus = true
this.selectedResult--
const input = this.$refs.input;
const textLength = input.value.length
setTimeout(() => {
input.focus()
input.setSelectionRange(textLength, textLength + 1)
}, 1)
},
handleInput(e){
this.selectedResult = 0