1
- import { TransitionGroup } from 'vue' ;
1
+ import { TransitionGroup } from 'vue' ;
2
2
import KeyCode from '../_util/KeyCode' ;
3
3
import PropTypes from '../_util/vue-types' ;
4
4
import classnames from 'classnames' ;
@@ -149,7 +149,7 @@ const Select = {
149
149
} ;
150
150
return {
151
151
...state ,
152
- _mirrorInputValue : state . _inputValue , // https://github.com/vueComponent/ant-design-vue/issues/1458
152
+ // _mirrorInputValue: state._inputValue, // https://github.com/vueComponent/ant-design-vue/issues/1458
153
153
...this . getDerivedState ( props , state ) ,
154
154
} ;
155
155
} ,
@@ -170,22 +170,10 @@ const Select = {
170
170
__propsSymbol__ ( ) {
171
171
Object . assign ( this . $data , this . getDerivedState ( getOptionProps ( this ) , this . $data ) ) ;
172
172
} ,
173
- _inputValue ( val ) {
174
- this . $data . _mirrorInputValue = val ;
175
- } ,
176
173
} ,
177
174
updated ( ) {
178
175
this . $nextTick ( ( ) => {
179
- if ( isMultipleOrTags ( this . $props ) ) {
180
- const inputNode = this . getInputDOMNode ( ) ;
181
- const mirrorNode = this . getInputMirrorDOMNode ( ) ;
182
- if ( inputNode && inputNode . value && mirrorNode ) {
183
- inputNode . style . width = '' ;
184
- inputNode . style . width = `${ mirrorNode . clientWidth + 10 } px` ;
185
- } else if ( inputNode ) {
186
- inputNode . style . width = '' ;
187
- }
188
- }
176
+ this . updateInputWidth ( ) ;
189
177
this . forcePopupAlign ( ) ;
190
178
} ) ;
191
179
} ,
@@ -199,6 +187,18 @@ const Select = {
199
187
}
200
188
} ,
201
189
methods : {
190
+ updateInputWidth ( ) {
191
+ if ( isMultipleOrTags ( this . $props ) ) {
192
+ const inputNode = this . getInputDOMNode ( ) ;
193
+ const mirrorNode = this . getInputMirrorDOMNode ( ) ;
194
+ if ( inputNode && inputNode . value && mirrorNode ) {
195
+ inputNode . style . width = '' ;
196
+ inputNode . style . width = `${ mirrorNode . clientWidth + 10 } px` ;
197
+ } else if ( inputNode ) {
198
+ inputNode . style . width = '' ;
199
+ }
200
+ }
201
+ } ,
202
202
getDerivedState ( nextProps , prevState ) {
203
203
const optionsInfo = prevState . _skipBuildOptionsInfo
204
204
? prevState . _optionsInfo
@@ -310,14 +310,7 @@ const Select = {
310
310
} ,
311
311
312
312
onInputChange ( e ) {
313
- const { value : val , composing } = e . target ;
314
- const { _inputValue = '' } = this . $data ;
315
- if ( e . isComposing || composing || _inputValue === val ) {
316
- this . setState ( {
317
- _mirrorInputValue : val ,
318
- } ) ;
319
- return ;
320
- }
313
+ const { value : val } = e . target ;
321
314
const { tokenSeparators } = this . $props ;
322
315
if (
323
316
isMultipleOrTags ( this . $props ) &&
@@ -639,20 +632,14 @@ const Select = {
639
632
getPlaceholderElement ( ) {
640
633
const { $props : props , $data : state } = this ;
641
634
let hidden = false ;
642
- if ( state . _mirrorInputValue ) {
635
+ if ( state . _inputValue ) {
643
636
hidden = true ;
644
637
}
645
638
const value = state . _value ;
646
639
if ( value . length ) {
647
640
hidden = true ;
648
641
}
649
- if (
650
- ! state . _mirrorInputValue &&
651
- isCombobox ( props ) &&
652
- value . length === 1 &&
653
- state . _value &&
654
- ! state . _value [ 0 ]
655
- ) {
642
+ if ( isCombobox ( props ) && value . length === 1 && state . _value && ! state . _value [ 0 ] ) {
656
643
hidden = false ;
657
644
}
658
645
const placeholder = props . placeholder ;
@@ -781,9 +768,11 @@ const Select = {
781
768
} ,
782
769
_getInputElement ( ) {
783
770
const props = this . $props ;
784
- const { _inputValue : inputValue , _mirrorInputValue } = this . $data ;
771
+ const { _inputValue : inputValue } = this . $data ;
785
772
const attrs = this . $attrs ;
786
- const defaultInput = < input { ...( attrs . id !== undefined ? { id : attrs . id } : { } ) } autoComplete = "off" /> ;
773
+ const defaultInput = (
774
+ < input { ...( attrs . id !== undefined ? { id : attrs . id } : { } ) } autoComplete = "off" />
775
+ ) ;
787
776
788
777
const inputElement = props . getInputElement ? props . getInputElement ( ) : defaultInput ;
789
778
const inputCls = classnames ( inputElement . class , {
@@ -816,7 +805,7 @@ const Select = {
816
805
onBlur : chaining ( this . inputBlur , inputEvents . onBlur ) ,
817
806
} ) }
818
807
< span ref = { this . saveInputMirrorRef } class = { `${ props . prefixCls } -search__field__mirror` } >
819
- { _mirrorInputValue }
808
+ { inputValue }
820
809
</ span >
821
810
</ div >
822
811
) ;
@@ -1206,7 +1195,7 @@ const Select = {
1206
1195
} ) ;
1207
1196
1208
1197
sel . push (
1209
- < MenuItemGroup key = { key } title = { label } class = { child . props ? .class } >
1198
+ < MenuItemGroup key = { key } title = { label } class = { child . props && child . props . class } >
1210
1199
{ ...innerItems }
1211
1200
</ MenuItemGroup > ,
1212
1201
) ;
@@ -1411,9 +1400,7 @@ const Select = {
1411
1400
tag : 'ul' ,
1412
1401
onAfterLeave : this . onChoiceAnimationLeave ,
1413
1402
} ) ;
1414
- innerNode = (
1415
- < TransitionGroup { ...transitionProps } > { selectedValueNodes } </ TransitionGroup >
1416
- ) ;
1403
+ innerNode = < TransitionGroup { ...transitionProps } > { selectedValueNodes } </ TransitionGroup > ;
1417
1404
} else {
1418
1405
innerNode = < ul > { selectedValueNodes } </ ul > ;
1419
1406
}
0 commit comments