From 6ac90b36c82febbd451e411cf1e564ecf018bc36 Mon Sep 17 00:00:00 2001 From: Armin Mehinovic Date: Tue, 8 Oct 2024 14:35:19 +0200 Subject: [PATCH] Use position instead of a lock flag to determine if the scroll value should be changed --- .../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(() => {