From bc60d8ac4c9ab7fffbc38420e8a6c5b7234830dd Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Sat, 13 May 2023 13:43:05 -0400 Subject: [PATCH] fix: throw error when freezing columns are wider than canvas (#773) - 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 --- slick.core.js | 2 +- slick.grid.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/slick.core.js b/slick.core.js index 62b748d6..ba3e78f9 100644 --- a/slick.core.js +++ b/slick.core.js @@ -845,7 +845,7 @@ } function width(el, value) { - if (!el) return; + if (!el || !el.getBoundingClientRect) return; if (value === undefined) { return el.getBoundingClientRect().width } diff --git a/slick.grid.js b/slick.grid.js index 0c7d842b..db8d2a8a 100644 --- a/slick.grid.js +++ b/slick.grid.js @@ -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);