Skip to content

Commit 458f91c

Browse files
committed
fix: Prevent grid cells vanishing during column resize after drag-and-drop reorder (#9530)
1 parent 5c9b26a commit 458f91c

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

src/draggable/grid/header/toolbar/SortZone.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class SortZone extends BaseSortZone {
230230
column.locked = newLocked
231231
} else {
232232
owner.items.forEach((item, index) => {
233-
item.vdom['aria-colindex'] = index + 1; // 1 based
233+
item.vdom['aria-colindex'] = index + 1 // 1 based
234234
});
235235

236236
owner.updateDepth = 2;

src/grid/Body.mjs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,22 +1336,25 @@ class GridBody extends Component {
13361336
let me = this,
13371337
columnPositions = me.columnPositions,
13381338
colPos = columnPositions.get(dataField),
1339-
colIndex = columnPositions.indexOf(colPos),
13401339
deltaWidth = newWidth - colPos.width,
13411340
count = columnPositions.getCount(),
1342-
i, minX, pos;
1341+
isFollowing = false,
1342+
i, pos;
13431343

13441344
if (deltaWidth === 0) {
13451345
return
13461346
}
13471347

1348-
// 1. Update the JS config caches
1349-
colPos.width = newWidth;
1350-
minX = colPos.x;
1348+
// 1. Update the JS config caches strictly by array order
1349+
for (i = 0; i < count; i++) {
1350+
pos = columnPositions.getAt(i);
13511351

1352-
for (i = colIndex + 1; i < count; i++) {
1353-
pos = columnPositions.getAt(i);
1354-
pos.x += deltaWidth;
1352+
if (pos.dataField === dataField) {
1353+
pos.width = newWidth;
1354+
isFollowing = true
1355+
} else if (isFollowing) {
1356+
pos.x += deltaWidth
1357+
}
13551358
}
13561359

13571360
me.setSilent({
@@ -1372,13 +1375,17 @@ class GridBody extends Component {
13721375

13731376
if (field) {
13741377
if (field === dataField) {
1375-
cell.style.width = newWidth + 'px';
1378+
cell.style.width = newWidth + 'px'
13761379
} else {
13771380
pos = columnPositions.get(field);
13781381

1379-
// Using x coordinate to check if it's a following column
1380-
if (pos && pos.x > minX) {
1381-
cell.style.left = pos.x + 'px';
1382+
if (pos) {
1383+
// Self-healing: if a previous drag left visibility: 'hidden' in the VDOM,
1384+
// cear it now to prevent the cell from vanishing during resize.
1385+
delete cell.style.visibility;
1386+
// Blindly apply the cache. If it's a preceding column,
1387+
// pos.x is unchanged and the VDOM engine ignores the delta.
1388+
cell.style.left = pos.x + 'px'
13821389
}
13831390
}
13841391
}

0 commit comments

Comments
 (0)