@@ -15,7 +15,7 @@ import type { CustomTagProps, DisplayValueType, Mode, RenderNode } from '../Base
1515import { isValidateOpenKey } from '../utils/keyUtil' ;
1616import useLock from '../hooks/useLock' ;
1717import type { PropType } from 'vue' ;
18- import { defineComponent } from 'vue' ;
18+ import { defineComponent , ref } from 'vue' ;
1919import createRef from '../../_util/createRef' ;
2020import PropTypes from '../../_util/vue-types' ;
2121import type { VueNode } from '../../_util/type' ;
@@ -124,7 +124,7 @@ const Selector = defineComponent<SelectorProps>({
124124 } as any ,
125125 setup ( props , { expose } ) {
126126 const inputRef = createRef ( ) ;
127- let compositionStatus = false ;
127+ let compositionStatus = ref ( false ) ;
128128
129129 // ====================== Input ======================
130130 const [ getInputMouseDown , setInputMouseDown ] = useLock ( 0 ) ;
@@ -140,7 +140,12 @@ const Selector = defineComponent<SelectorProps>({
140140 props . onInputKeyDown ( event ) ;
141141 }
142142
143- if ( which === KeyCode . ENTER && props . mode === 'tags' && ! compositionStatus && ! props . open ) {
143+ if (
144+ which === KeyCode . ENTER &&
145+ props . mode === 'tags' &&
146+ ! compositionStatus . value &&
147+ ! props . open
148+ ) {
144149 // When menu isn't open, OptionList won't trigger a value change
145150 // So when enter is pressed, the tag's input value should be emitted here to let selector know
146151 props . onSearchSubmit ( ( event . target as HTMLInputElement ) . value ) ;
@@ -163,17 +168,17 @@ const Selector = defineComponent<SelectorProps>({
163168 let pastedText = null ;
164169
165170 const triggerOnSearch = ( value : string ) => {
166- if ( props . onSearch ( value , true , compositionStatus ) !== false ) {
171+ if ( props . onSearch ( value , true , compositionStatus . value ) !== false ) {
167172 props . onToggleOpen ( true ) ;
168173 }
169174 } ;
170175
171176 const onInputCompositionStart = ( ) => {
172- compositionStatus = true ;
177+ compositionStatus . value = true ;
173178 } ;
174179
175180 const onInputCompositionEnd = ( e : InputEvent ) => {
176- compositionStatus = false ;
181+ compositionStatus . value = false ;
177182 // Trigger search again to support `tokenSeparators` with typewriting
178183 if ( props . mode !== 'combobox' ) {
179184 triggerOnSearch ( ( e . target as HTMLInputElement ) . value ) ;
@@ -251,6 +256,7 @@ const Selector = defineComponent<SelectorProps>({
251256 onInputMouseDown : onInternalInputMouseDown ,
252257 onInputChange,
253258 onInputPaste,
259+ compositionStatus : compositionStatus . value ,
254260 onInputCompositionStart,
255261 onInputCompositionEnd,
256262 } ;
0 commit comments