afc163
5 years ago
No known key found for this signature in database
GPG Key ID: 5F00908D72002306
2 changed files with
22 additions and
2 deletions
-
components/cascader/__tests__/index.test.js
-
components/cascader/index.tsx
|
|
@ -451,4 +451,24 @@ describe('Cascader', () => { |
|
|
|
); |
|
|
|
errorSpy.mockRestore(); |
|
|
|
}); |
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/17690
|
|
|
|
it('should not breaks when children is null', () => { |
|
|
|
const optionsWithChildrenNull = [ |
|
|
|
{ |
|
|
|
value: 'zhejiang', |
|
|
|
label: 'Zhejiang', |
|
|
|
children: [ |
|
|
|
{ |
|
|
|
value: 'hangzhou', |
|
|
|
label: 'Hangzhou', |
|
|
|
children: null, |
|
|
|
}, |
|
|
|
], |
|
|
|
}, |
|
|
|
]; |
|
|
|
expect(() => { |
|
|
|
mount(<Cascader options={optionsWithChildrenNull} />); |
|
|
|
}).not.toThrow(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
@ -206,8 +206,8 @@ function flattenTree( |
|
|
|
|
|
|
|
const defaultDisplayRender = (label: string[]) => label.join(' / '); |
|
|
|
|
|
|
|
function warningValueNotExist(list: CascaderOptionType[] = [], fieldNames: FieldNamesType = {}) { |
|
|
|
list.forEach(item => { |
|
|
|
function warningValueNotExist(list: CascaderOptionType[], fieldNames: FieldNamesType = {}) { |
|
|
|
(list || []).forEach(item => { |
|
|
|
const valueFieldName = fieldNames.value || 'value'; |
|
|
|
warning(valueFieldName in item, 'Cascader', 'Not found `value` in `options`.'); |
|
|
|
warningValueNotExist(item[fieldNames.children || 'children'], fieldNames); |
|
|
|