File tree Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ import OptGroup from './OptGroup';
50
50
import Option from './Option' ;
51
51
import OptionList from './OptionList' ;
52
52
import SelectContext from './SelectContext' ;
53
- import { hasValue , toArray } from './utils/commonUtil' ;
53
+ import { hasValue , isComboNoValue , toArray } from './utils/commonUtil' ;
54
54
import { fillFieldNames , flattenOptions , injectPropsWithOption } from './utils/valueUtil' ;
55
55
import warningProps , { warningNullOptions } from './utils/warningPropsUtil' ;
56
56
@@ -307,8 +307,8 @@ const Select = React.forwardRef(
307
307
const rawLabeledValues = React . useMemo ( ( ) => {
308
308
const values = convert2LabelValues ( internalValue ) ;
309
309
310
- // combobox no need save value when it's no value
311
- if ( mode === 'combobox' && ! values [ 0 ] ?. value ) {
310
+ // combobox no need save value when it's no value (exclude value equal 0)
311
+ if ( mode === 'combobox' && isComboNoValue ( values [ 0 ] ?. value ) ) {
312
312
return [ ] ;
313
313
}
314
314
Original file line number Diff line number Diff line change @@ -17,6 +17,11 @@ export function hasValue(value) {
17
17
return value !== undefined && value !== null ;
18
18
}
19
19
20
+ /** combo mode no value judgment function */
21
+ export function isComboNoValue ( value ) {
22
+ return ! value && value !== 0 ;
23
+ }
24
+
20
25
function isTitleType ( title : any ) {
21
26
return [ 'string' , 'number' ] . includes ( typeof title ) ;
22
27
}
Original file line number Diff line number Diff line change @@ -600,4 +600,10 @@ describe('Select.Combobox', () => {
600
600
601
601
jest . useRealTimers ( ) ;
602
602
} ) ;
603
+
604
+ // https://github.com/ant-design/ant-design/issues/43936
605
+ it ( 'combobox mode not show 0 value' , ( ) => {
606
+ const wrapper = mount ( < Select mode = "combobox" value = { 0 } /> ) ;
607
+ expect ( wrapper . find ( 'input' ) . props ( ) . value ) . toBe ( '0' ) ;
608
+ } ) ;
603
609
} ) ;
You can’t perform that action at this time.
0 commit comments