Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

fixed issue with initial value not being preserved for v-model #59

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/components/VueBootstrapTypeahead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ export default {
text: this.serializer(d)
}
})
},

inputValue: {
get: function() {
return this.value || ""
},

set: function(newValue) {
this.inputValue = newValue

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be this.value = newValue?

}
}
},

Expand All @@ -137,7 +147,6 @@ export default {
this.$emit('input', evt.text)
}

this.inputValue = evt.text
this.$emit('hit', evt.data)
this.$refs.input.blur()
this.isFocused = false
Expand All @@ -152,8 +161,6 @@ export default {
},

handleInput(newValue) {
this.inputValue = newValue

// If v-model is being used, emit an input event
if (typeof this.value !== 'undefined') {
this.$emit('input', newValue)
Expand All @@ -163,8 +170,7 @@ export default {

data() {
return {
isFocused: false,
inputValue: ''
isFocused: false
}
},

Expand Down