@@ -2,7 +2,7 @@ import TransBtn from '../TransBtn';
22import type { InnerSelectorProps } from './interface' ;
33import Input from './Input' ;
44import type { Ref , PropType } from 'vue' ;
5- import { computed , defineComponent , onMounted , shallowRef , watch } from 'vue' ;
5+ import { ref , watchEffect , computed , defineComponent , onMounted , shallowRef , watch } from 'vue' ;
66import classNames from '../../_util/classNames' ;
77import pickAttrs from '../../_util/pickAttrs' ;
88import PropTypes from '../../_util/vue-types' ;
@@ -24,6 +24,8 @@ type SelectorProps = InnerSelectorProps & {
2424 tagRender ?: ( props : CustomTagProps ) => VueNode ;
2525 onToggleOpen : any ;
2626
27+ compositionStatus : boolean ;
28+
2729 // Motion
2830 choiceTransitionName ?: string ;
2931
@@ -46,7 +48,7 @@ const props = {
4648 autocomplete : String ,
4749 activeDescendantId : String ,
4850 tabindex : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . string ] ) ,
49-
51+ compositionStatus : Boolean ,
5052 removeIcon : PropTypes . any ,
5153 choiceTransitionName : String ,
5254
@@ -91,11 +93,14 @@ const SelectSelector = defineComponent<SelectorProps>({
9193 ( ) =>
9294 props . mode === 'tags' || ( ( props . showSearch && ( props . open || focused . value ) ) as boolean ) ,
9395 ) ;
94-
96+ const targetValue = ref ( '' ) ;
97+ watchEffect ( ( ) => {
98+ targetValue . value = inputValue . value ;
99+ } ) ;
95100 // We measure width and set to the input immediately
96101 onMounted ( ( ) => {
97102 watch (
98- inputValue ,
103+ targetValue ,
99104 ( ) => {
100105 inputWidth . value = measureRef . value . scrollWidth ;
101106 } ,
@@ -202,6 +207,14 @@ const SelectSelector = defineComponent<SelectorProps>({
202207 return defaultRenderSelector ( content , content , false ) ;
203208 }
204209
210+ const handleInput = ( e : Event ) => {
211+ const composing = ( e . target as any ) . composing ;
212+ targetValue . value = ( e . target as any ) . value ;
213+ if ( ! composing ) {
214+ props . onInputChange ( e ) ;
215+ }
216+ } ;
217+
205218 return ( ) => {
206219 const {
207220 id,
@@ -215,14 +228,13 @@ const SelectSelector = defineComponent<SelectorProps>({
215228 autocomplete,
216229 activeDescendantId,
217230 tabindex,
218- onInputChange ,
231+ compositionStatus ,
219232 onInputPaste,
220233 onInputKeyDown,
221234 onInputMouseDown,
222235 onInputCompositionStart,
223236 onInputCompositionEnd,
224237 } = props ;
225-
226238 // >>> Input Node
227239 const inputNode = (
228240 < div
@@ -241,10 +253,10 @@ const SelectSelector = defineComponent<SelectorProps>({
241253 autocomplete = { autocomplete }
242254 editable = { inputEditable . value }
243255 activeDescendantId = { activeDescendantId }
244- value = { inputValue . value }
256+ value = { targetValue . value }
245257 onKeydown = { onInputKeyDown }
246258 onMousedown = { onInputMouseDown }
247- onChange = { onInputChange }
259+ onChange = { handleInput }
248260 onPaste = { onInputPaste }
249261 onCompositionstart = { onInputCompositionStart }
250262 onCompositionend = { onInputCompositionEnd }
@@ -256,7 +268,7 @@ const SelectSelector = defineComponent<SelectorProps>({
256268
257269 { /* Measure Node */ }
258270 < span ref = { measureRef } class = { `${ selectionPrefixCls . value } -search-mirror` } aria-hidden >
259- { inputValue . value }
271+ { targetValue . value }
260272 </ span >
261273 </ div >
262274 ) ;
@@ -277,7 +289,7 @@ const SelectSelector = defineComponent<SelectorProps>({
277289 return (
278290 < >
279291 { selectionNode }
280- { ! values . length && ! inputValue . value && (
292+ { ! values . length && ! inputValue . value && ! compositionStatus && (
281293 < span class = { `${ selectionPrefixCls . value } -placeholder` } > { placeholder } </ span >
282294 ) }
283295 </ >
0 commit comments