@@ -15,7 +15,7 @@ import type { CustomTagProps, DisplayValueType, Mode, RenderNode } from '../Base
15
15
import { isValidateOpenKey } from '../utils/keyUtil' ;
16
16
import useLock from '../hooks/useLock' ;
17
17
import type { PropType } from 'vue' ;
18
- import { defineComponent } from 'vue' ;
18
+ import { defineComponent , ref } from 'vue' ;
19
19
import createRef from '../../_util/createRef' ;
20
20
import PropTypes from '../../_util/vue-types' ;
21
21
import type { VueNode } from '../../_util/type' ;
@@ -124,7 +124,7 @@ const Selector = defineComponent<SelectorProps>({
124
124
} as any ,
125
125
setup ( props , { expose } ) {
126
126
const inputRef = createRef ( ) ;
127
- let compositionStatus = false ;
127
+ let compositionStatus = ref ( false ) ;
128
128
129
129
// ====================== Input ======================
130
130
const [ getInputMouseDown , setInputMouseDown ] = useLock ( 0 ) ;
@@ -140,7 +140,12 @@ const Selector = defineComponent<SelectorProps>({
140
140
props . onInputKeyDown ( event ) ;
141
141
}
142
142
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
+ ) {
144
149
// When menu isn't open, OptionList won't trigger a value change
145
150
// So when enter is pressed, the tag's input value should be emitted here to let selector know
146
151
props . onSearchSubmit ( ( event . target as HTMLInputElement ) . value ) ;
@@ -163,17 +168,17 @@ const Selector = defineComponent<SelectorProps>({
163
168
let pastedText = null ;
164
169
165
170
const triggerOnSearch = ( value : string ) => {
166
- if ( props . onSearch ( value , true , compositionStatus ) !== false ) {
171
+ if ( props . onSearch ( value , true , compositionStatus . value ) !== false ) {
167
172
props . onToggleOpen ( true ) ;
168
173
}
169
174
} ;
170
175
171
176
const onInputCompositionStart = ( ) => {
172
- compositionStatus = true ;
177
+ compositionStatus . value = true ;
173
178
} ;
174
179
175
180
const onInputCompositionEnd = ( e : InputEvent ) => {
176
- compositionStatus = false ;
181
+ compositionStatus . value = false ;
177
182
// Trigger search again to support `tokenSeparators` with typewriting
178
183
if ( props . mode !== 'combobox' ) {
179
184
triggerOnSearch ( ( e . target as HTMLInputElement ) . value ) ;
@@ -251,6 +256,7 @@ const Selector = defineComponent<SelectorProps>({
251
256
onInputMouseDown : onInternalInputMouseDown ,
252
257
onInputChange,
253
258
onInputPaste,
259
+ compositionStatus : compositionStatus . value ,
254
260
onInputCompositionStart,
255
261
onInputCompositionEnd,
256
262
} ;
0 commit comments