Add ft-input enter listener the vue way (#2879)

This commit is contained in:
absidue 2022-11-21 07:37:38 +01:00 committed by GitHub
parent 577413212f
commit 5b67803c32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 17 deletions

View File

@ -103,8 +103,6 @@ export default Vue.extend({
this.id = this._uid
this.inputData = this.value
this.updateVisibleDataList()
setTimeout(this.addListener, 200)
},
methods: {
handleClick: function (e) {
@ -132,11 +130,10 @@ export default Vue.extend({
this.handleActionIconChange()
this.updateVisibleDataList()
const inputElement = document.getElementById(this.id)
inputElement.value = ''
this.$refs.input.value = ''
// Focus on input element after text is clear for better UX
inputElement.focus()
this.$refs.input.focus()
this.$emit('clear')
},
@ -190,18 +187,6 @@ export default Vue.extend({
}
},
addListener: function () {
const inputElement = document.getElementById(this.id)
if (inputElement !== null) {
inputElement.addEventListener('keydown', (event) => {
if (event.key === 'Enter') {
this.handleClick(event)
}
})
}
},
handleOptionClick: function (index) {
this.searchState.showOptions = false
this.inputData = this.visibleDataList[index]

View File

@ -50,6 +50,7 @@
@focus="handleFocus"
@blur="handleInputBlur"
@keydown="handleKeyDown"
@keydown.enter="handleClick"
>
<font-awesome-icon
v-if="showActionButton"