fix: NestedSelect级联下拉开启onlyChildren&onlyleaf后,导致下拉最后一项默认选中问题 (#9215)

* fix: 测试:「组件」级联下拉开启onlyleaf后,存在属性互斥的情况,组件表现不符合预期(onlyChildren&onlyleaf)

* fix: 测试:「组件」级联下拉开启onlyleaf后,存在属性互斥的情况
,组件表现不符合预期(onlyChildren&onlyleaf)

* fix: 测试:「组件」级联下拉开启onlyleaf后,存在属性互斥的情况
,组件表现不符合预期(onlyChildren&onlyleaf)
This commit is contained in:
sqzhou 2023-12-22 10:31:31 +08:00 committed by GitHub
parent ed2940ac4e
commit 2955833fd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

@ -218,3 +218,33 @@ describe.only('Renderer:NestedSelect with onlyLeaf', () => {
expect(queryByText(optionWithChild)).toBeNull();
});
});
test('test onlyChildren&onlyleaf', async () => {
const {container} = await setupNestedSelect({
"onlyLeaf": true,
"multiple": true,
"options": [
{"label":"选项A","value":"A"},
{"label":"选项B","value":"B",
"children":[
{"label":"选项b1","value":"b1"},
{"label":"选项b2","value":"b2"}
]
},
{"label":"选项C-children为null","value":"C","children":[]},
{"label":"选项d","value":"d",
"children":[
{"label":"选项D1-CHILDREN为null","value":"D1","children":[]}
]}
]
});
const trigger = container.querySelector('.cxd-ResultBox');
expect(trigger).toBeInTheDocument();
fireEvent.click(trigger!);
await wait(200);
const hasActive = container.querySelector('.is-active');
expect(hasActive).toBeNull();
});

View File

@ -689,6 +689,7 @@ export default class NestedSelectControl extends React.Component<
if (
!selfChecked &&
onlyChildren &&
multiple &&
this.isParentNode(option) &&
this.allChecked(option.children!)
) {