Skip to content

Commit

Permalink
Add ft-input enter listener the vue way (#2879)
Browse files Browse the repository at this point in the history
  • Loading branch information
absidue committed Nov 21, 2022
1 parent 5774132 commit 5b67803
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
19 changes: 2 additions & 17 deletions src/renderer/components/ft-input/ft-input.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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')
},
Expand Down Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions src/renderer/components/ft-input/ft-input.vue
Expand Up @@ -50,6 +50,7 @@
@focus="handleFocus"
@blur="handleInputBlur"
@keydown="handleKeyDown"
@keydown.enter="handleClick"
>
<font-awesome-icon
v-if="showActionButton"
Expand Down

0 comments on commit 5b67803

Please sign in to comment.