Skip to content

Commit 3511adc

Browse files
committedFeb 14, 2025
fix(grid): [grid] 修复表格展开状态下拖拽无法正确渲染bug
1 parent 441c376 commit 3511adc

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed
 

‎packages/vue/src/grid/src/body/src/body.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ function renderRow(args) {
564564
attrs: {
565565
'data-rowid': rowid
566566
},
567-
key: rowKey || treeConfig ? rowid : $rowIndex,
567+
key: rowid,
568568
on: trOn
569569
},
570570
tableColumn.map((column, $columnIndex) => {
@@ -608,7 +608,7 @@ function renderRowExpanded(args) {
608608
'tr',
609609
{
610610
class: 'tiny-grid-body__expanded-row',
611-
key: `expand_${rowid}`,
611+
key: `expand_${rowid}${rowIndex}`,
612612
on: trOn
613613
},
614614
[
@@ -897,7 +897,8 @@ export default defineComponent({
897897
render() {
898898
let { $parent: $table } = this as any
899899
let { $grid, isCenterEmpty, keyboardConfig = {}, mouseConfig = {}, renderEmpty } = $table
900-
let { scrollLoad, tableColumn, tableData, tableLayout } = $table
900+
let { scrollLoad, tableColumn, tableLayout } = $table
901+
const tableData = $table.$grid.data || $table.tableData
901902
let $slots = $grid.slots
902903
let isCenterCls = isCenterEmpty ? 'is__center' : ''
903904

‎packages/vue/src/grid/src/dragger/src/rowDrop.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,18 @@ export const createHandlerOnEnd = ({ _vm, refresh }) => {
5959
}
6060
const options = { children: (_vm.treeConfig || {}).children || 'children' }
6161
const targetTrElem = event.item
62-
const { parentNode: wrapperElem, previousElementSibling: prevTrElem } = targetTrElem
62+
const { parentNode: wrapperElem, previousElementSibling } = targetTrElem
63+
let prevTrElem = previousElementSibling
6364
// 这里优先使用用户通过props传递过来的表格数据,所以拖拽后会改变原始数据
6465
const tableTreeData = _vm.data || _vm.tableData
6566
const selfRow = _vm.getRowNode(targetTrElem).item
6667
const selfNode = findTree(tableTreeData, (row) => row === selfRow, options)
6768
const isScrollYLoad = _vm.scrollYLoad
6869
if (!isScrollYLoad) {
6970
if (prevTrElem) {
71+
if (prevTrElem.classList.contains('tiny-grid-body__expanded-row')) {
72+
prevTrElem = prevTrElem.previousElementSibling
73+
}
7074
// 移动到节点
7175
const prevRow = _vm.getRowNode(prevTrElem).item
7276
const prevNode = findTree(tableTreeData, (row) => row === prevRow, options)

0 commit comments

Comments
 (0)