Skip to content

Commit 69f4777

Browse files
committed
fix(BTable): row.index is now correctly passed to the cell slot template
1 parent cb3b8a2 commit 69f4777

File tree

1 file changed

+24
-17
lines changed
  • packages/bootstrap-vue-3/src/components/BTable

1 file changed

+24
-17
lines changed

packages/bootstrap-vue-3/src/components/BTable/BTable.vue

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@
6363
</tr>
6464
</thead>
6565
<tbody>
66-
<template v-for="(tr, ind) in computedItems" :key="ind">
66+
<template v-for="(item, itemIndex) in computedItems" :key="itemIndex">
6767
<tr
68-
:class="getRowClasses(tr)"
69-
@click.prevent="onRowClick(tr, ind, $event)"
70-
@dblclick.prevent="onRowDblClick(tr, ind, $event)"
71-
@mouseenter.prevent="onRowMouseEnter(tr, ind, $event)"
72-
@mouseleave.prevent="onRowMouseLeave(tr, ind, $event)"
68+
:class="getRowClasses(item)"
69+
@click.prevent="onRowClick(item, itemIndex, $event)"
70+
@dblclick.prevent="onRowDblClick(item, itemIndex, $event)"
71+
@mouseenter.prevent="onRowMouseEnter(item, itemIndex, $event)"
72+
@mouseleave.prevent="onRowMouseLeave(item, itemIndex, $event)"
7373
>
7474
<td
7575
v-if="addSelectableCell"
@@ -79,33 +79,40 @@
7979
}"
8080
>
8181
<slot name="selectCell">
82-
<span :class="selectedItems.has(tr) ? 'text-primary' : ''">🗹</span>
82+
<span :class="selectedItems.has(item) ? 'text-primary' : ''">🗹</span>
8383
</slot>
8484
</td>
8585
<td
86-
v-for="(field, index) in computedFields"
86+
v-for="field in computedFields"
8787
:key="field.key"
8888
v-bind="field.tdAttr"
89-
:class="getFieldRowClasses(field, tr)"
89+
:class="getFieldRowClasses(field, item)"
9090
>
9191
<slot
9292
v-if="$slots['cell(' + field.key + ')'] || $slots['cell()']"
9393
:name="$slots['cell(' + field.key + ')'] ? 'cell(' + field.key + ')' : 'cell()'"
94-
:value="tr[field.key]"
95-
:index="index"
96-
:item="tr"
94+
:value="item[field.key]"
95+
:index="itemIndex"
96+
:item="item"
9797
:field="field"
9898
:items="items"
99-
:toggle-details="() => toggleRowDetails(tr)"
100-
:details-showing="tr._showDetails"
99+
:toggle-details="() => toggleRowDetails(item)"
100+
:details-showing="item._showDetails"
101101
/>
102-
<template v-else>{{ tr[field.key] }}</template>
102+
<template v-else>{{ item[field.key] }}</template>
103103
</td>
104104
</tr>
105105

106-
<tr v-if="tr._showDetails === true && $slots['row-details']" :class="getRowClasses(tr)">
106+
<tr
107+
v-if="item._showDetails === true && $slots['row-details']"
108+
:class="getRowClasses(item)"
109+
>
107110
<td :colspan="computedFieldsTotal">
108-
<slot name="row-details" :item="tr" :toggle-details="() => toggleRowDetails(tr)" />
111+
<slot
112+
name="row-details"
113+
:item="item"
114+
:toggle-details="() => toggleRowDetails(item)"
115+
/>
109116
</td>
110117
</tr>
111118
</template>

0 commit comments

Comments
 (0)