fix: options value 为 undefined 不进行 normalize (#5263)

Co-authored-by: tooeast <liuzedong02@baidu.com>
This commit is contained in:
sansiro 2022-08-30 16:46:32 +08:00 committed by RUNZE LU
parent 39a7397dfc
commit 8bd11effcd
2 changed files with 7 additions and 1 deletions

View File

@ -570,6 +570,10 @@ export function registerOptionsControl(config: OptionsConfig) {
whetherValueNormal() {
const {value, joinValues, extractValue, multiple} = this.props;
if (value === undefined) {
return true;
}
if (joinValues !== false || (!multiple && extractValue === true)) {
return typeof value === 'string' || typeof value === 'number';
}
@ -610,7 +614,8 @@ export function registerOptionsControl(config: OptionsConfig) {
}
if (joinValues !== false) {
if (typeof value === 'string' || typeof value === 'number') return;
if (!value || typeof value === 'string' || typeof value === 'number')
return;
const selectedOptions = formItem.getSelectedOptions(value);

View File

@ -562,6 +562,7 @@ test('Renderer:checkboxes with defaultCheckAll & inline', async () => {
const Ins = container.querySelectorAll('.cxd-CheckboxesControl');
expect(Ins[0]!).toHaveClass('is-inline');
expect(Ins[1]!).not.toHaveClass('is-inline');
await wait(200);
fireEvent.click(getByText('Submit'));
await waitFor(() => {