Skip to content

Commit

Permalink
fix(VTextField): Skip value property update if IME composing string
Browse files Browse the repository at this point in the history
  • Loading branch information
kouqon authored and johnleider committed Apr 20, 2020
1 parent bf3fad2 commit 5eca8d7
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/vuetify/src/components/VTextField/VTextField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ interface options extends InstanceType<typeof baseMixins> {

const dirtyTypes = ['color', 'file', 'time', 'date', 'datetime-local', 'week', 'month']

interface InputEvent extends UIEvent {
isComposing: Boolean
}
interface KeyboardEvent extends UIEvent {
keyCode: Number
isComposing: Boolean
}

/* @vue/component */
export default baseMixins.extend<options>().extend({
name: 'v-text-field',
Expand Down Expand Up @@ -448,12 +456,14 @@ export default baseMixins.extend<options>().extend({
}
},
onInput (e: Event) {
const target = e.target as HTMLInputElement
this.internalValue = target.value
this.badInput = target.validity && target.validity.badInput
if (!(e as InputEvent).isComposing) {
const target = e.target as HTMLInputElement
this.internalValue = target.value
this.badInput = target.validity && target.validity.badInput
}
},
onKeyDown (e: KeyboardEvent) {
if (e.keyCode === keyCodes.enter) this.$emit('change', this.internalValue)
if (!e.isComposing && e.keyCode === keyCodes.enter) { this.$emit('change', this.internalValue) }

this.$emit('keydown', e)
},
Expand Down

0 comments on commit 5eca8d7

Please sign in to comment.