fix(grid): fix drag error when tbody not render (#3538)

This commit is contained in:
gimmyhehe 2025-06-26 15:16:27 +08:00 committed by GitHub
parent 768fc7b709
commit 0e74d5f38a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 15 deletions

View File

@ -750,6 +750,19 @@ export default defineComponent({
hooks.watch(body, (body) => body && resizeObserver.observe(body))
hooks.watch(tbody, (tbody) => {
if (tbody && $table.dropConfig) {
// 初始化行列拖拽
const { plugin, row = true, column = true, scheme } = $table.dropConfig
plugin && row && (vm.rowSortable = $table.rowDrop(body.value))
if (scheme !== 'v2') {
plugin && column && (vm.columnSortable = $table.columnDrop(body.value))
}
}
})
hooks.watch(customFooter, (customFooter) => customFooter && resizeObserver.observe(customFooter))
hooks.watchEffect(() => {
@ -767,21 +780,6 @@ export default defineComponent({
vm._throttleScrollHandler = throttle($table.optimizeOpts.scrollDelay, vm.handleScroll)
body.value?.addEventListener('scroll', vm._throttleScrollHandler)
// 初始化行列拖拽
setTimeout(() => {
const { dropConfig } = $table
if (dropConfig) {
const { plugin, row = true, column = true, scheme } = dropConfig
plugin && row && (vm.rowSortable = $table.rowDrop(body.value))
if (scheme !== 'v2') {
plugin && column && (vm.columnSortable = $table.columnDrop(body.value))
}
}
}, 50)
})
hooks.onBeforeUnmount(() => {