From 90d135e8d681083e2903a60e8135daec88e98ac5 Mon Sep 17 00:00:00 2001 From: Joost Molenkamp Date: Fri, 9 Sep 2022 20:36:33 +0200 Subject: [PATCH] ScrollResize: redraw header on scrollbar hiding during feature initialization --- features/scrollResize/dataTables.scrollResize.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/features/scrollResize/dataTables.scrollResize.js b/features/scrollResize/dataTables.scrollResize.js index 7daeedd..6c6a1f4 100644 --- a/features/scrollResize/dataTables.scrollResize.js +++ b/features/scrollResize/dataTables.scrollResize.js @@ -90,6 +90,17 @@ var ScrollResize = function ( dt ) this._attach(); this._size(); + + // Redraw the header if the scrollbar was visible before feature + // initialization, but no longer after initialization. Otherwise, + // the header width would differ from the body width, because the + // scrollbar is no longer present. + var settings = dt.settings()[0]; + var divBodyEl = settings.nScrollBody; + var scrollBarVis = divBodyEl.scrollHeight > divBodyEl.clientHeight; + if (settings.scrollBarVis && !scrollBarVis) { + dt.columns.adjust(); + } };