Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});