Skip to content

Commit b08f935

Browse files
authored
Merge pull request #1065 from dnum-mi/fix/#1038-dsfr-data-table-pagination
fix(DsfrDataTable): 🐛 corrige l’incohérence des id des cases cochées
2 parents b1ef746 + e6701ee commit b08f935

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/components/DsfrDataTable/DsfrDataTable.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,20 @@ const sortedRows = computed(() => {
104104
}
105105
return _sortedRows
106106
})
107-
const finalRows = computed(() => {
108-
const rowKeys = props.headersRow.map((header) => {
109-
if (typeof header !== 'object') {
110-
return header
111-
}
112-
return header.key
113-
})
107+
const rowKeys = computed(() => props.headersRow.map((header) => {
108+
if (typeof header !== 'object') {
109+
return header
110+
}
111+
return header.key
112+
}))
113+
const rowKeyIndex = computed(() => rowKeys.value.findIndex(key => key === props.rowKey))
114114
115+
const finalRows = computed(() => {
115116
const rows = sortedRows.value.map((row) => {
116117
if (Array.isArray(row)) {
117118
return row
118119
}
119-
return rowKeys.map(key => typeof row !== 'object' ? row : row[key] ?? row)
120+
return rowKeys.value.map(key => typeof row !== 'object' ? row : row[key] ?? row)
120121
})
121122
122123
if (props.pagination) {
@@ -225,11 +226,10 @@ function copyToClipboard (text: string) {
225226
role="columnheader"
226227
>
227228
<div class="fr-checkbox-group fr-checkbox-group--sm">
228-
<!-- @vue-expect-error TS2538 -->
229229
<input
230230
:id="`row-select-${id}-${idx}`"
231231
v-model="selection"
232-
:value="rows[idx][rowKey] ?? `row-${idx}`"
232+
:value="row[rowKeyIndex] ?? `row-${idx}`"
233233
type="checkbox"
234234
>
235235
<label

0 commit comments

Comments
 (0)