fix(components): [table] toggleRowSelection restores previous behavior (#17884)

closed #17870
This commit is contained in:
qiang
2024-08-15 21:05:48 +08:00
committed by GitHub
parent 797e39dbe7
commit deb0be1777
2 changed files with 6 additions and 9 deletions

View File

@@ -800,7 +800,7 @@ describe('Table.vue', () => {
},
template: `
<el-table ref="table" :data="testData" @${prop}="handleEvent">
<el-table-column type="selection" />
<el-table-column type="selection" :selectable="selectable" />
<el-table-column prop="name" />
<el-table-column prop="release" />
<el-table-column prop="director" />
@@ -813,6 +813,9 @@ describe('Table.vue', () => {
this.fireCount++
this.selection = selection
},
selectable(row) {
return row.id !== 1
},
},
data() {
@@ -844,7 +847,7 @@ describe('Table.vue', () => {
const vm = wrapper.vm
vm.$refs.table.toggleAllSelection()
await doubleWait()
expect(vm.selection.length).toEqual(5)
expect(vm.selection.length).toEqual(4)
vm.$refs.table.toggleAllSelection()
await doubleWait()

View File

@@ -197,13 +197,7 @@ function useWatcher<T>() {
children: instance?.store?.states?.childrenColumnName.value,
checkStrictly: instance?.store?.states?.checkStrictly.value,
}
const changed = toggleRowStatus(
selection.value,
row,
selected,
treeProps,
selectable.value
)
const changed = toggleRowStatus(selection.value, row, selected, treeProps)
if (changed) {
const newSelection = (selection.value || []).slice()
// 调用 API 修改选中值,不触发 select 事件