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';
5050import Option from './Option' ;
5151import OptionList from './OptionList' ;
5252import SelectContext from './SelectContext' ;
53- import { hasValue , toArray } from './utils/commonUtil' ;
53+ import { hasValue , isComboNoValue , toArray } from './utils/commonUtil' ;
5454import { fillFieldNames , flattenOptions , injectPropsWithOption } from './utils/valueUtil' ;
5555import warningProps , { warningNullOptions } from './utils/warningPropsUtil' ;
5656
@@ -307,8 +307,8 @@ const Select = React.forwardRef(
307307 const rawLabeledValues = React . useMemo ( ( ) => {
308308 const values = convert2LabelValues ( internalValue ) ;
309309
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 ) ) {
312312 return [ ] ;
313313 }
314314
Original file line number Diff line number Diff line change @@ -17,6 +17,11 @@ export function hasValue(value) {
1717 return value !== undefined && value !== null ;
1818}
1919
20+ /** combo mode no value judgment function */
21+ export function isComboNoValue ( value ) {
22+ return ! value && value !== 0 ;
23+ }
24+
2025function isTitleType ( title : any ) {
2126 return [ 'string' , 'number' ] . includes ( typeof title ) ;
2227}
Original file line number Diff line number Diff line change @@ -600,4 +600,10 @@ describe('Select.Combobox', () => {
600600
601601 jest . useRealTimers ( ) ;
602602 } ) ;
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+ } ) ;
603609} ) ;
You can’t perform that action at this time.
0 commit comments