Skip to content

Commit b23f2de

Browse files
authoredNov 11, 2024··
fix(Table): data outdated when rows change (#2600)
1 parent 7154254 commit b23f2de

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed
 

‎src/runtime/components/data/Table.vue

+12-2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105

106106
<slot
107107
v-else
108+
:key="retriggerSlot"
108109
:name="`${column.key}-data`"
109110
:column="column"
110111
:row="row"
@@ -132,7 +133,7 @@
132133
</template>
133134

134135
<script lang="ts">
135-
import { computed, defineComponent, toRaw, toRef } from 'vue'
136+
import { computed, defineComponent, ref, toRaw, toRef, watch } from 'vue'
136137
import type { PropType, AriaAttributes } from 'vue'
137138
import { upperFirst } from 'scule'
138139
import { defu } from 'defu'
@@ -284,6 +285,8 @@ export default defineComponent({
284285
})
285286
})
286287
288+
const retriggerSlot = ref(null)
289+
287290
const savedSort = { column: sort.value.column, direction: null }
288291
289292
const rows = computed(() => {
@@ -466,6 +469,12 @@ export default defineComponent({
466469
return undefined
467470
}
468471
472+
watch(rows, () => {
473+
retriggerSlot.value = new Date()
474+
}, {
475+
deep: true
476+
})
477+
469478
return {
470479
// eslint-disable-next-line vue/no-dupe-keys
471480
ui,
@@ -493,7 +502,8 @@ export default defineComponent({
493502
toggleOpened,
494503
getAriaSort,
495504
isExpanded,
496-
shouldRenderColumnInFirstPlace
505+
shouldRenderColumnInFirstPlace,
506+
retriggerSlot
497507
}
498508
}
499509
})

0 commit comments

Comments
 (0)
Please sign in to comment.