Fix ft-input from rewriting itself when search suggestions are active

This commit is contained in:
Preston 2020-06-19 15:58:59 -04:00
parent 6e5a1a1085
commit 0428891773
4 changed files with 4 additions and 10 deletions

View File

@ -49,6 +49,7 @@ export default Vue.extend({
}, },
mounted: function () { mounted: function () {
this.id = this._uid this.id = this._uid
this.inputData = this.value
setTimeout(this.addListener, 200) setTimeout(this.addListener, 200)
}, },
@ -57,9 +58,8 @@ export default Vue.extend({
this.$emit('click', this.inputData) this.$emit('click', this.inputData)
}, },
handleInput: function (input) { handleInput: function () {
this.inputData = input this.$emit('input', this.inputData)
this.$emit('input', input)
}, },
addListener: function () { addListener: function () {

View File

@ -15,7 +15,7 @@
<input <input
:id="id" :id="id"
:list="idDataList" :list="idDataList"
:value="value" v-model="inputData"
class="ft-input" class="ft-input"
type="text" type="text"
:placeholder="placeholder" :placeholder="placeholder"

View File

@ -17,7 +17,6 @@ export default Vue.extend({
component: this, component: this,
windowWidth: 0, windowWidth: 0,
showFilters: false, showFilters: false,
searchValue: '',
searchSuggestionsDataList: [] searchSuggestionsDataList: []
} }
}, },
@ -126,20 +125,17 @@ export default Vue.extend({
getSearchSuggestionsLocal: function (query) { getSearchSuggestionsLocal: function (query) {
if (query === '') { if (query === '') {
this.searchSuggestionsDataList = [] this.searchSuggestionsDataList = []
this.searchValue = ''
return return
} }
ytSuggest(query).then((results) => { ytSuggest(query).then((results) => {
this.searchSuggestionsDataList = results this.searchSuggestionsDataList = results
this.searchValue = query
}) })
}, },
getSearchSuggestionsInvidious: function (query) { getSearchSuggestionsInvidious: function (query) {
if (query === '') { if (query === '') {
this.searchSuggestionsDataList = [] this.searchSuggestionsDataList = []
this.searchValue = ''
return return
} }
@ -153,7 +149,6 @@ export default Vue.extend({
this.$store.dispatch('invidiousAPICall', searchPayload).then((results) => { this.$store.dispatch('invidiousAPICall', searchPayload).then((results) => {
this.searchSuggestionsDataList = results.suggestions this.searchSuggestionsDataList = results.suggestions
this.searchValue = query
}).error((err) => { }).error((err) => {
console.log(err) console.log(err)
if (this.backendFallback) { if (this.backendFallback) {

View File

@ -40,7 +40,6 @@
class="searchInput" class="searchInput"
:is-search="true" :is-search="true"
:data-list="searchSuggestionsDataList" :data-list="searchSuggestionsDataList"
:value="searchValue"
@input="getSearchSuggestionsDebounce" @input="getSearchSuggestionsDebounce"
@click="goToSearch" @click="goToSearch"
/> />