fix(components): [table] fix absence of theadRef bug (#21454)

fix(components): [TableHeader] fix absence of theadRef bug
This commit is contained in:
Mamaev Iurii
2025-07-22 03:13:53 +03:00
committed by GitHub
parent ea38e306b1
commit 4bb8d8ce04

View File

@@ -4,6 +4,7 @@ import {
h,
inject,
nextTick,
onBeforeUnmount,
onMounted,
reactive,
ref,
@@ -80,8 +81,9 @@ export default defineComponent({
const saveIndexSelection = reactive(new Map())
const theadRef = ref()
let delayId: ReturnType<typeof setTimeout> | undefined
const updateFixedColumnStyle = () => {
setTimeout(() => {
delayId = setTimeout(() => {
if (saveIndexSelection.size > 0) {
saveIndexSelection.forEach((column, key) => {
const el = theadRef.value.querySelector(
@@ -98,6 +100,12 @@ export default defineComponent({
}
watch(saveIndexSelection, updateFixedColumnStyle)
onBeforeUnmount(() => {
if (delayId) {
clearTimeout(delayId)
delayId = undefined
}
})
onMounted(async () => {
// Need double await, because updateColumns is executed after nextTick for now