mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
fix(components): [table] selection-change event emit incorrectly (#19618)
* feat(components): [table] fix 'selection-change' event emit incorrectly * fix(components): [table] add test case
This commit is contained in:
@@ -1848,12 +1848,14 @@ describe('Table.vue', () => {
|
||||
const testData = getTestData() as any
|
||||
testData[1].childrenTest = [
|
||||
{
|
||||
id: 21,
|
||||
name: "A Bug's Life copy 1",
|
||||
release: '1998-11-25-1',
|
||||
director: 'John Lasseter',
|
||||
runtime: 95,
|
||||
},
|
||||
{
|
||||
id: 22,
|
||||
name: "A Bug's Life copy 2",
|
||||
release: '1998-11-25-2',
|
||||
director: 'John Lasseter',
|
||||
@@ -1892,6 +1894,19 @@ describe('Table.vue', () => {
|
||||
await doubleWait()
|
||||
expect(wrapper.vm.selected.length).toEqual(2)
|
||||
expect(wrapper.findAll('.el-checkbox')[3].classes()).include('is-checked')
|
||||
|
||||
await (wrapper.vm.treeProps.checkStrictly = false)
|
||||
wrapper.findAll('.el-checkbox')[0].trigger('click')
|
||||
wrapper.findAll('.el-checkbox')[0].trigger('click')
|
||||
await doubleWait()
|
||||
expect(wrapper.vm.selected.length).toEqual(0)
|
||||
wrapper.findAll('.el-checkbox')[0].trigger('click')
|
||||
await doubleWait()
|
||||
wrapper.findAll('.el-checkbox')[3].trigger('click')
|
||||
await doubleWait()
|
||||
wrapper.findAll('.el-checkbox')[0].trigger('click')
|
||||
await doubleWait()
|
||||
expect(wrapper.vm.selected.length).toEqual(getTestData().length + 2)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -318,7 +318,7 @@ export function toggleRowStatus<T>(
|
||||
isArray(row[tableTreeProps.children])
|
||||
) {
|
||||
row[tableTreeProps.children].forEach((item) => {
|
||||
toggleRowStatus(
|
||||
const childChanged = toggleRowStatus(
|
||||
statusArr,
|
||||
item,
|
||||
newVal ?? !included,
|
||||
@@ -327,6 +327,9 @@ export function toggleRowStatus<T>(
|
||||
_rowIndex + 1
|
||||
)
|
||||
_rowIndex += getChildrenCount(item) + 1
|
||||
if (childChanged) {
|
||||
changed = childChanged
|
||||
}
|
||||
})
|
||||
}
|
||||
return changed
|
||||
|
||||
Reference in New Issue
Block a user