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(VDataTable): correctly update the value of showSelectAll #19762

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export const VDataTableHeaders = genericComponent<VDataTableHeadersSlots>()({
if (slots[columnSlotName]) return slots[columnSlotName]!(columnSlotProps)

if (column.key === 'data-table-select') {
return slots['header.data-table-select']?.(columnSlotProps) ?? (showSelectAll && (
return slots['header.data-table-select']?.(columnSlotProps) ?? (showSelectAll.value && (
<VCheckboxBtn
modelValue={ allSelected.value }
indeterminate={ someSelected.value && !allSelected.value }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,20 @@ describe('VDataTable', () => {
.should('deep.equal', [[2], [1]])
})

// https:/vuetifyjs/vuetify/issues/19069
it('should update the select all checkbox when changing the select-strategy', () => {
const strategy = ref('single')
cy.mount(() => (
<Application>
<VDataTable select-strategy={ strategy.value } items={ DESSERT_ITEMS } headers={ DESSERT_HEADERS } showSelect />
</Application>
)).get('thead .v-selection-control').should('not.exist')
.then(() => strategy.value = 'all')
.get('thead .v-selection-control').should('exist')
.then(() => strategy.value = 'page')
.get('thead .v-selection-control').should('exist')
})

describe('slots', () => {
it('should have top slot', () => {
cy.mount(() => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export function provideSelection (
})
return !!items.length && isSelected(items)
})
const showSelectAll = computed(() => selectStrategy.value.showSelectAll)

const data = {
toggleSelect,
Expand All @@ -172,7 +173,7 @@ export function provideSelection (
isSomeSelected,
someSelected,
allSelected,
showSelectAll: selectStrategy.value.showSelectAll,
showSelectAll,
}

provide(VDataTableSelectionSymbol, data)
Expand Down
Loading