Skip to content

Commit

Permalink
fix: throw error when freezing columns are wider than canvas (#773)
Browse files Browse the repository at this point in the history
- closes #667
- freezing columns cannot be wider than the actual grid canvas because when that happens, the viewport scroll becomes hidden behind the canvas... so let's throw an error advising the user to make adjustments
  • Loading branch information
ghiscoding authored May 13, 2023
1 parent de88e68 commit bc60d8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion slick.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@
}

function width(el, value) {
if (!el) return;
if (!el || !el.getBoundingClientRect) return;
if (value === undefined) {
return el.getBoundingClientRect().width
}
Expand Down
5 changes: 5 additions & 0 deletions slick.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,11 @@ if (typeof Slick === "undefined") {
utils.width(_headerR, headersWidthR);

if (hasFrozenColumns()) {
const cWidth = utils.width(_container) || 0;
if (cWidth > 0 && canvasWidthL > cWidth) {
throw new Error('[SlickGrid] Frozen columns cannot be wider than the actual grid container width. '
+ 'Make sure to have less columns freezed or make your grid container wider');
}
utils.width(_canvasTopR, canvasWidthR);

utils.width(_paneHeaderL, canvasWidthL);
Expand Down

0 comments on commit bc60d8a

Please sign in to comment.