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

Use an indeterminate checkbox pattern for p-table select all. #1161

Merged
merged 1 commit into from
Mar 19, 2024
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
11 changes: 8 additions & 3 deletions src/components/Table/PTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
<PTableRow>
<template v-if="showMultiselect">
<PTableData class="p-table__checkbox-cell">
<p-checkbox v-model="allSelected" />
<p-tooltip :text="selectAllModel ? 'Deselect all' : 'Select all'">
<p-checkbox
v-model="selectAllModel"
:indeterminate="internalSelectedRows.length && internalSelectedRows.length < selectableRows.length"
/>
</p-tooltip>
</PTableData>
</template>

Expand Down Expand Up @@ -96,9 +101,9 @@
},
})

const allSelected = computed({
const selectAllModel = computed({
get() {
return internalSelectedRows.value.length === selectableRows.value.length
return internalSelectedRows.value.length > 0
},
set(value) {
internalSelectedRows.value = value ? selectableRows.value : []
Expand Down
Loading