From 018dc1db7e5dee84f23bd2235fb11a4f44279003 Mon Sep 17 00:00:00 2001 From: Armin Mehinovic <4390250+arminmeh@users.noreply.github.com> Date: Tue, 8 Oct 2024 20:17:55 +0200 Subject: [PATCH] [DataGrid] Fix scrollbar position not being updated after `scrollToIndexes` (#14877) --- .../virtualization/GridVirtualScrollbar.tsx | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/packages/x-data-grid/src/components/virtualization/GridVirtualScrollbar.tsx b/packages/x-data-grid/src/components/virtualization/GridVirtualScrollbar.tsx index e5bf5410f4ccf..912ed05493532 100644 --- a/packages/x-data-grid/src/components/virtualization/GridVirtualScrollbar.tsx +++ b/packages/x-data-grid/src/components/virtualization/GridVirtualScrollbar.tsx @@ -70,8 +70,8 @@ const GridVirtualScrollbar = React.forwardRef(null); const contentRef = React.useRef(null); const classes = useUtilityClasses(rootProps, props.position); @@ -96,34 +96,28 @@ const GridVirtualScrollbar = React.forwardRef { const scroller = apiRef.current.virtualScrollerRef.current!; const scrollbar = scrollbarRef.current!; - if (isLocked.current) { - isLocked.current = false; + if (scrollbar[propertyScroll] === lastPositionScrollbar.current) { return; } - isLocked.current = true; const value = scrollbar[propertyScroll] / scrollbarInnerSize; scroller[propertyScroll] = value * contentSize; + + lastPositionScroller.current = scroller[propertyScroll]; }); useOnMount(() => {