Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a980e7e

Browse files
author
Alberto Iannaccone
committed
always set the internal state value
1 parent e32ed9c commit a980e7e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

‎arduino-ide-extension/src/browser/dialogs/settings/settings-step-input.tsx‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ const SettingsStepInput: React.FC<SettingsStepInputProps> = (
3737
return Math.min(Math.max(value, min), max);
3838
};
3939

40+
const setValidValue = (value: number): void => {
41+
const clampedValue = clamp(value, minValue, maxValue);
42+
setValueState({ currentValue: clampedValue, isEmptyString: false });
43+
setSettingsStateValue(clampedValue);
44+
};
45+
4046
const onStep = (
4147
roundingOperation: 'ceil' | 'floor',
4248
stepOperation: (a: number, b: number) => number
@@ -47,9 +53,7 @@ const SettingsStepInput: React.FC<SettingsStepInputProps> = (
4753
valueRoundedToScale === currentValue
4854
? stepOperation(currentValue, step)
4955
: valueRoundedToScale;
50-
const newValue = clamp(calculatedValue, minValue, maxValue);
51-
52-
setSettingsStateValue(newValue);
56+
setValidValue(calculatedValue);
5357
};
5458

5559
const onStepUp = (): void => {
@@ -87,10 +91,7 @@ const SettingsStepInput: React.FC<SettingsStepInputProps> = (
8791
}
8892

8993
if (currentValue !== initialValue) {
90-
/* If the user input is a number, clamp it to the min and max values */
91-
const newValue = clamp(currentValue, minValue, maxValue);
92-
93-
setSettingsStateValue(newValue);
94+
setValidValue(currentValue);
9495
}
9596
};
9697

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /