Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Table): select all rows reactivity issue #2200

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/runtime/components/data/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,18 @@ export default defineComponent({
}

function selectAllRows () {
// Create a new array to ensure reactivity
const newSelected = [...selected.value]

// If the row is not already selected, add it to the newSelected array
props.rows.forEach((row) => {
// If the row is already selected, don't select it again
if (isSelected(row)) {
return
if (!isSelected(row)) {
newSelected.push(row)
}

// @ts-ignore
selected.value.push(row)
})

// Reassign the array to trigger Vue's reactivity
selected.value = newSelected
}

function onChange (checked: boolean) {
Expand Down