mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-05 04:37:47 +08:00
fix(cascader-panel): no loaded nodes should not be checked (#1583)
* fix(cascader): no loaded nodes should not be checked * fix(cascader): no loaded nodes should not be checked * fix(cascader): it should be indeterminate if some child are not loaded
This commit is contained in:
parent
1655c2aa11
commit
598b798555
@ -578,6 +578,57 @@ describe('CascaderPanel.vue', () => {
|
||||
expect(wrapper.find(`.is-active`).text()).toBe('option2')
|
||||
})
|
||||
|
||||
test('no loaded nodes should not be checked', async () => {
|
||||
const wrapper = _mount({
|
||||
template: `
|
||||
<cascader-panel
|
||||
:props="props"
|
||||
/>
|
||||
`,
|
||||
data() {
|
||||
return {
|
||||
props: {
|
||||
multiple: true,
|
||||
lazy: true,
|
||||
lazyLoad (node, resolve) {
|
||||
const { level } = node
|
||||
setTimeout(() => {
|
||||
const nodes = Array.from({ length: level + 1 })
|
||||
.map(() => {
|
||||
++id
|
||||
return {
|
||||
value: id,
|
||||
label: `option${id}`,
|
||||
leaf: id === 3,
|
||||
}
|
||||
})
|
||||
resolve(nodes)
|
||||
}, 1000)
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
jest.runAllTimers()
|
||||
await nextTick()
|
||||
const firstMenu = wrapper.findAll(MENU)[0]
|
||||
const firstOption = wrapper.find(NODE)
|
||||
await firstOption.trigger('click')
|
||||
jest.runAllTimers()
|
||||
await nextTick()
|
||||
|
||||
await firstMenu.find(CHECKBOX).find('input').trigger('click')
|
||||
|
||||
const secondMenu = wrapper.findAll(MENU)[1]
|
||||
expect(secondMenu.exists()).toBe(true)
|
||||
expect(firstMenu.find(CHECKBOX).classes('is-checked')).toBe(false)
|
||||
expect(firstMenu.find(CHECKBOX).classes('is-indeterminate')).toBe(true)
|
||||
expect(secondMenu.findAll(CHECKBOX)[0].classes('is-checked')).toBe(false)
|
||||
expect(secondMenu.findAll(CHECKBOX)[0].classes('is-indeterminate')).toBe(false)
|
||||
expect(secondMenu.findAll(CHECKBOX)[1].classes('is-checked')).toBe(true)
|
||||
expect(secondMenu.findAll(CHECKBOX)[1].classes('is-indeterminate')).toBe(false)
|
||||
})
|
||||
|
||||
test('getCheckedNodes and clearCheckedNodes', () => {
|
||||
const wrapper = mount(CascaderPanel, {
|
||||
props: {
|
||||
|
@ -147,8 +147,8 @@ export default class Node {
|
||||
return c + num
|
||||
}, 0)
|
||||
|
||||
this.checked = checked
|
||||
this.indeterminate = checkedNum !== totalNum && checkedNum > 0
|
||||
this.checked = this.loaded && this.children.every(child => child.loaded && child.checked) && checked
|
||||
this.indeterminate = this.loaded && checkedNum !== totalNum && checkedNum > 0
|
||||
}
|
||||
|
||||
doCheck(checked: boolean) {
|
||||
|
Loading…
Reference in New Issue
Block a user