Skip to content

Commit

Permalink
fix(Slider): defaultValue now updates the slider
Browse files Browse the repository at this point in the history
  • Loading branch information
DSil committed Jun 19, 2023
1 parent 390e995 commit 62dd911
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/orbit-components/src/Slider/index.tsx
Expand Up @@ -106,19 +106,19 @@ const PureSlider = ({
const [focused, setFocused] = React.useState(false);
const { rtl } = theme;

const updateValue = (newValue: Value) => {
valueRef.current = newValue;
setValue(newValue);
};

React.useEffect(() => {
const newValue = Array.isArray(defaultValue)
? defaultValue.map(item => Number(item))
: Number(defaultValue);

setValue(newValue);
updateValue(newValue);
}, [defaultValue]);

const updateValue = (newValue: Value) => {
valueRef.current = newValue;
setValue(newValue);
};

const handleKeyDown = (event: KeyboardEvent) => {
if (event.ctrlKey || event.shiftKey || event.altKey) return;
const eventCode = Number(event.code);
Expand Down

0 comments on commit 62dd911

Please sign in to comment.