Skip to content

Commit 269e4c8

Browse files
committed
fix: Resolve locked column VDOM thrashing and throttle pinning addon (#9485)
1 parent c6523ba commit 269e4c8

2 files changed

Lines changed: 40 additions & 6 deletions

File tree

src/grid/Row.mjs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,36 @@ class Row extends Component {
474474
if (column.hideMode !== 'removeDom' || column.locked) {
475475
isMounted = i >= mountedColumns[0] && i <= mountedColumns[1];
476476

477+
// Cell Recycling for Permanent Cells
478+
if (recycle && oldCellMap) {
479+
let oldNode = oldCellMap.get(column.dataField);
480+
481+
if (oldNode && oldNode.data?.recordId === recordId) {
482+
columnPosition = columnPositions.get(column.dataField);
483+
if (columnPosition) {
484+
oldNode.style.left = columnPosition.x + 'px';
485+
oldNode.style.width = columnPosition.width + 'px';
486+
487+
if (isMounted || column.locked) {
488+
if (columnPosition.hidden) {
489+
oldNode.style.visibility = 'hidden'
490+
} else {
491+
oldNode.style.visibility = null;
492+
oldNode.style.display = null;
493+
}
494+
} else {
495+
if (column.hideMode === 'visibility') {
496+
oldNode.style.visibility = 'hidden'
497+
} else if (column.hideMode === 'display') {
498+
oldNode.style.display = 'none'
499+
}
500+
}
501+
}
502+
vdom.cn.push(oldNode);
503+
continue;
504+
}
505+
}
506+
477507
cellConfig = me.applyRendererOutput({
478508
cache,
479509
cellId : `${me.id}__${column.dataField}`,
@@ -498,7 +528,7 @@ class Row extends Component {
498528
};
499529

500530
// Visibility Logic
501-
if (isMounted) {
531+
if (isMounted || column.locked) {
502532
if (columnPosition.hidden) {
503533
cellConfig.style.visibility = 'hidden'
504534
}

src/main/addon/GridColumnScrollPinning.mjs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ class GridColumnScrollPinning extends Base {
6464

6565
// Apply CSS variables to the root container node for inheritance
6666
node.style.setProperty('--grid-locked-start-offset', `${scrollLeft}px`);
67-
node.style.setProperty('--grid-locked-end-offset', `${scrollLeft - (scrollWidth - clientWidth)}px`)
67+
node.style.setProperty('--grid-locked-end-offset', `${scrollLeft - (scrollWidth - clientWidth)}px`);
68+
69+
state.ticking = false;
6870
}
6971

7072
/**
71-
* Triggered by native browser scroll. Synchronous execution.
73+
* Triggered by native browser scroll. Uses rAF to batch style recalculations.
7274
* @param {Event} event
7375
* @protected
7476
*/
@@ -85,8 +87,9 @@ class GridColumnScrollPinning extends Base {
8587
}
8688
}
8789

88-
if (state) {
89-
me.applyPinning(state)
90+
if (state && !state.ticking) {
91+
state.ticking = true;
92+
requestAnimationFrame(() => me.applyPinning(state));
9093
}
9194
}
9295

@@ -104,7 +107,8 @@ class GridColumnScrollPinning extends Base {
104107
me.registrations.set(id, {
105108
id,
106109
containerId,
107-
containerNode
110+
containerNode,
111+
ticking: false
108112
});
109113

110114
containerNode.addEventListener('scroll', me.boundOnScroll, {passive: true});

0 commit comments

Comments
 (0)