Skip to content

Commit f4b6396

Browse files
authored
Merge pull request #623 from klee-contrib/ne-pas-tronquer-si-pas-de-pagination
fix([DsfrTable]): 🐛 Le tableau ne devrait pas être tronqué lorsque la pagination n'est pas activée
2 parents cd48030 + 3907498 commit f4b6396

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/components/DsfrTable/DsfrTable.vue

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts" setup>
2-
import { ref, watch } from 'vue'
2+
import { computed, ref, watch } from 'vue'
33
import DsfrTableRow, { type DsfrTableRowProps } from './DsfrTableRow.vue'
44
import DsfrTableHeaders from './DsfrTableHeaders.vue'
55
import { type DsfrTableHeadersProps } from './DsfrTableHeaders.vue'
@@ -30,15 +30,17 @@ const pageCount = ref(props.rows.length > optionSelected.value ? Math.ceil(props
3030
const paginationOptions = [5, 10, 25, 50, 100]
3131
const returnLowestLimit = () => currentPage.value * optionSelected.value - optionSelected.value
3232
const returnHighestLimit = () => currentPage.value * optionSelected.value
33-
let truncatedResults = props.rows.slice(returnLowestLimit(), returnHighestLimit())
3433
35-
watch(() => optionSelected.value, (newVal) => {
36-
props.rows.length > optionSelected.value ? pageCount.value = Math.ceil(props.rows.length / newVal) : pageCount.value = 1
37-
truncatedResults = props.rows.slice(returnLowestLimit(), returnHighestLimit())
34+
watch(() => optionSelected.value, (newVal, OldVal) => {
35+
pageCount.value = props.rows.length > optionSelected.value ? Math.ceil(props.rows.length / newVal) : 1
3836
})
3937
40-
watch(() => currentPage.value, () => {
41-
truncatedResults = props.rows.slice(returnLowestLimit(), returnHighestLimit())
38+
const truncatedResults = computed(() => {
39+
if(props.pagination) {
40+
return props.rows.slice(returnLowestLimit(), returnHighestLimit())
41+
}
42+
43+
return props.rows;
4244
})
4345
4446
const goFirstPage = () => { currentPage.value = 1 }

0 commit comments

Comments
 (0)