Skip to content

Commit

Permalink
fix(DsfrDataTable): 🐛 fix selection with selectAll
Browse files Browse the repository at this point in the history
  • Loading branch information
iNeoO committed Oct 31, 2024
1 parent d9bba2b commit 7b14e2d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/components/DsfrDataTable/DsfrDataTable.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { computed } from 'vue'
import DsfrPagination from '../DsfrPagination/DsfrPagination.vue'
import VIcon from '../VIcon/VIcon.vue'
Expand Down Expand Up @@ -128,17 +128,15 @@ function selectAll (bool: boolean) {
if (bool) {
const keyIndex = props.headersRow.findIndex(header => (header as DsfrDataTableHeaderCellObject).key ?? header)
selection.value = finalRows.value.map(row => row[keyIndex] as string)
} else {
selection.value.length = 0
}
selection.value!.length = 0
}
const wholeSelection = ref(false)
function checkSelection () {
wholeSelection.value = selection.value.length === finalRows.value.length
}
const wholeSelection = computed(() => selection.value.length === finalRows.value.length)
function onPaginationOptionsChange () {
emit('update:current-page', 0)
wholeSelection.value = false
selection.value.length = 0
}
Expand All @@ -151,6 +149,7 @@ function copyToClipboard (text: string) {
<div
class="fr-table"
>
{{ selection }}
<div class="fr-table__wrapper">
<div class="fr-table__container">
<div class="fr-table__content">
Expand Down Expand Up @@ -231,7 +230,6 @@ function copyToClipboard (text: string) {
v-model="selection"
:value="rows[idx][rowKey] ?? `row-${idx}`"
type="checkbox"
@change="checkSelection()"
>
<label
class="fr-label"
Expand Down Expand Up @@ -317,6 +315,7 @@ function copyToClipboard (text: string) {
<DsfrPagination
v-model:current-page="currentPage"
:pages="pages"
@update:current-page="selection.length = 0"
/>
</div>
</template>
Expand Down

0 comments on commit 7b14e2d

Please sign in to comment.