diff --git a/packages/vuetify/src/components/VDataTable/VDataTableHeaders.tsx b/packages/vuetify/src/components/VDataTable/VDataTableHeaders.tsx index c2755cd9619..d075842d788 100644 --- a/packages/vuetify/src/components/VDataTable/VDataTableHeaders.tsx +++ b/packages/vuetify/src/components/VDataTable/VDataTableHeaders.tsx @@ -180,7 +180,7 @@ export const VDataTableHeaders = genericComponent()({ 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 && ( { .should('deep.equal', [[2], [1]]) }) + // https://github.com/vuetifyjs/vuetify/issues/19069 + it('should update the select all checkbox when changing the select-strategy', () => { + const strategy = ref('single') + cy.mount(() => ( + + + + )).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(() => ( diff --git a/packages/vuetify/src/components/VDataTable/composables/select.ts b/packages/vuetify/src/components/VDataTable/composables/select.ts index 419aecef2fb..fcea69f19a7 100644 --- a/packages/vuetify/src/components/VDataTable/composables/select.ts +++ b/packages/vuetify/src/components/VDataTable/composables/select.ts @@ -163,6 +163,7 @@ export function provideSelection ( }) return !!items.length && isSelected(items) }) + const showSelectAll = computed(() => selectStrategy.value.showSelectAll) const data = { toggleSelect, @@ -172,7 +173,7 @@ export function provideSelection ( isSomeSelected, someSelected, allSelected, - showSelectAll: selectStrategy.value.showSelectAll, + showSelectAll, } provide(VDataTableSelectionSymbol, data)