Skip to content

Commit

Permalink
fix: toggling frozen rows should recalc scroll height, closes #737 (#774
Browse files Browse the repository at this point in the history
)

- when changing frozen rows via `setOptions`, it should recalculate each viewports (top/bottom)
- the previous code skipped scroll height recalculation and that caused the issue identified in #737
  • Loading branch information
ghiscoding authored May 14, 2023
1 parent bc60d8a commit 46db491
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion slick.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ if (typeof Slick === "undefined") {
var cssShow = { position: 'absolute', visibility: 'hidden', display: 'block' };
var _hiddenParents;
var oldProps = [];
var enforceFrozenRowHeightRecalc = false;
var columnResizeDragging = false;
var slickDraggableInstance = null;
var slickMouseWheelInstances = [];
Expand Down Expand Up @@ -3221,6 +3222,11 @@ if (typeof Slick === "undefined") {
validateAndEnforceOptions();
setFrozenOptions();

// when user changed frozen row option, we need to force a recalculation of each viewport heights
if (args.frozenBottom !== undefined) {
enforceFrozenRowHeightRecalc = true;
}

_viewport.forEach(function (view) {
view.style["overflow-y"] = options.autoHeight ? "hidden" : "auto";
});
Expand Down Expand Up @@ -3970,7 +3976,7 @@ if (typeof Slick === "undefined") {
}
}

if (h !== oldH) {
if (h !== oldH || enforceFrozenRowHeightRecalc) {
if (hasFrozenRows && !options.frozenBottom) {
utils.height(_canvasBottomL, h);

Expand All @@ -3983,6 +3989,7 @@ if (typeof Slick === "undefined") {
}

scrollTop = _viewportScrollContainerY.scrollTop;
enforceFrozenRowHeightRecalc = false; // reset enforce flag
}

var oldScrollTopInRange = (scrollTop + offset <= th - tempViewportH);
Expand Down

0 comments on commit 46db491

Please sign in to comment.