diff --git a/src/util.ts b/src/util.ts index ede7901f..ede3b454 100644 --- a/src/util.ts +++ b/src/util.ts @@ -74,9 +74,14 @@ export function convertOptions( ): InternalDataNode[] { function injectValue(list: DataNode[], parentValue = ''): InternalDataNode[] { return (list || []).map(option => { - const newValue = parentValue - ? connectValue([parentValue, option[fieldValue]]) - : option[fieldValue]; + let newValue = option[fieldValue]; + if (parentValue) { + newValue = connectValue([parentValue, option[fieldValue]]); + } else if (typeof newValue === 'number') { + // Since we will convert all the value to string, we need get this + newValue = String(newValue); + } + const cloneOption = { ...option, [fieldValue]: newValue, diff --git a/tests/index.spec.tsx b/tests/index.spec.tsx index 74f05419..65b59acf 100644 --- a/tests/index.spec.tsx +++ b/tests/index.spec.tsx @@ -780,5 +780,6 @@ describe('Cascader.Basic', () => { wrapper.clickOption(0, 0); expect(onValueChange).toHaveBeenCalledWith([1], expect.anything()); + expect(wrapper.find('.rc-cascader-selection-item').text()).toEqual('One'); }); });