Skip to content

Commit 68124de

Browse files
authored
fix(Table): select all rows reactivity issue (#2200)
1 parent bae7f3f commit 68124de

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

‎src/runtime/components/data/Table.vue

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,18 @@ export default defineComponent({
326326
}
327327
328328
function selectAllRows () {
329+
// Create a new array to ensure reactivity
330+
const newSelected = [...selected.value]
331+
332+
// If the row is not already selected, add it to the newSelected array
329333
props.rows.forEach((row) => {
330-
// If the row is already selected, don't select it again
331-
if (isSelected(row)) {
332-
return
334+
if (!isSelected(row)) {
335+
newSelected.push(row)
333336
}
334-
335-
// @ts-ignore
336-
selected.value.push(row)
337337
})
338+
339+
// Reassign the array to trigger Vue's reactivity
340+
selected.value = newSelected
338341
}
339342
340343
function onChange (checked: boolean) {

0 commit comments

Comments
 (0)