Skip to content

Commit

Permalink
Update useSlider to accurately track lastChangeValue.
Browse files Browse the repository at this point in the history
  • Loading branch information
good-jinu committed Dec 20, 2024
1 parent 8a4ebea commit 7e07151
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/mui-material/src/Slider/useSlider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ export function useSlider(parameters: UseSliderParameters): UseSliderReturnValue
value: { value, name },
});

lastChangedValue.current = value;
onChange(clonedEvent, value, thumbIndex);
});

Expand Down Expand Up @@ -352,7 +353,7 @@ export function useSlider(parameters: UseSliderParameters): UseSliderReturnValue
}

if (onChangeCommitted) {
onChangeCommitted(event, newValue);
onChangeCommitted(event, lastChangedValue.current ?? newValue);
}
};

Expand Down Expand Up @@ -569,7 +570,6 @@ export function useSlider(parameters: UseSliderParameters): UseSliderReturnValue
}

if (handleChange && !areValuesEqual(newValue, valueDerived)) {
lastChangedValue.current = newValue;
handleChange(nativeEvent, lastChangedValue.current ?? newValue, activeIndex);
}
});
Expand Down

0 comments on commit 7e07151

Please sign in to comment.