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 ab1e076
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 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,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);
}
});

Expand Down

0 comments on commit ab1e076

Please sign in to comment.