From ab1e076732b99f3f7c6f3d41898f8c96226df906 Mon Sep 17 00:00:00 2001 From: good-jinu Date: Fri, 20 Dec 2024 09:44:39 +0900 Subject: [PATCH] Update useSlider to accurately track lastChangeValue. --- packages/mui-material/src/Slider/useSlider.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/mui-material/src/Slider/useSlider.ts b/packages/mui-material/src/Slider/useSlider.ts index 4bf503b65b437d..71fef5b75129bb 100644 --- a/packages/mui-material/src/Slider/useSlider.ts +++ b/packages/mui-material/src/Slider/useSlider.ts @@ -263,6 +263,7 @@ export function useSlider(parameters: UseSliderParameters): UseSliderReturnValue value: { value, name }, }); + lastChangedValue.current = value; onChange(clonedEvent, value, thumbIndex); }); @@ -352,7 +353,7 @@ export function useSlider(parameters: UseSliderParameters): UseSliderReturnValue } if (onChangeCommitted) { - onChangeCommitted(event, newValue); + onChangeCommitted(event, lastChangedValue.current ?? newValue); } }; @@ -569,8 +570,7 @@ export function useSlider(parameters: UseSliderParameters): UseSliderReturnValue } if (handleChange && !areValuesEqual(newValue, valueDerived)) { - lastChangedValue.current = newValue; - handleChange(nativeEvent, lastChangedValue.current ?? newValue, activeIndex); + handleChange(nativeEvent, newValue, activeIndex); } });