Skip to content

Commit

Permalink
fix(comp:select): trigger handleInput when onCompositionEnd (#801)
Browse files Browse the repository at this point in the history
fix #786
  • Loading branch information
danranVm committed Mar 12, 2022
1 parent 93231ab commit d157f0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/components/input/src/useInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export function useInput(
watch(accessor.valueRef, () => syncValue())

const isComposing = ref(false)
const handleInput = (evt: Event) => {
callEmit(props.onInput, evt)
const handleInput = (evt: Event, emitInput = true) => {
emitInput && callEmit(props.onInput, evt)
if (isComposing.value) {
return
}
Expand All @@ -96,7 +96,7 @@ export function useInput(
callEmit(props.onCompositionEnd, evt)
if (isComposing.value) {
isComposing.value = false
handleInput(evt)
handleInput(evt, false)
}
}

Expand Down
7 changes: 4 additions & 3 deletions packages/components/select/src/composables/useInputState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ export function useInputState(
}

const handleCompositionEnd = (evt: CompositionEvent) => {
callEmit(props.onCompositionEnd, evt)
if (isComposing.value) {
isComposing.value = false
handleInput(evt, false)
}
callEmit(props.onCompositionEnd, evt)
}

const handleInput = (evt: Event) => {
callEmit(props.onInput, evt)
const handleInput = (evt: Event, emitInput = true) => {
emitInput && callEmit(props.onInput, evt)
if (isComposing.value) {
return
}
Expand Down

0 comments on commit d157f0c

Please sign in to comment.