fix: step
This commit is contained in:
parent
3584d32820
commit
8430ff9992
@ -219,8 +219,10 @@ export default function SliderOptions({ question }: Props) {
|
||||
});
|
||||
}}
|
||||
onBlur={({ target }) => {
|
||||
const min = Number(question.content.range.split("—")[0]);
|
||||
const max = Number(question.content.range.split("—")[1]);
|
||||
const step = Number(target.value);
|
||||
const range = max - min;
|
||||
|
||||
if (step > max) {
|
||||
updateQuestion(question.id, (question) => {
|
||||
@ -229,6 +231,14 @@ export default function SliderOptions({ question }: Props) {
|
||||
question.content.step = max;
|
||||
});
|
||||
}
|
||||
|
||||
if (range % step) {
|
||||
updateQuestion(question.id, (question) => {
|
||||
if (question.type !== "number") return;
|
||||
|
||||
question.content.step = 1;
|
||||
});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
|
@ -43,14 +43,7 @@ export const Number = ({ currentQuestion }: NumberProps) => {
|
||||
|
||||
const min = window.Number(currentQuestion.content.range.split("—")[0]);
|
||||
const max = window.Number(currentQuestion.content.range.split("—")[1]);
|
||||
const step = currentQuestion.content.step;
|
||||
const sliderValue =
|
||||
answer ||
|
||||
(currentQuestion.content.start < min || currentQuestion.content.start > max
|
||||
? min
|
||||
: currentQuestion.content.start) +
|
||||
"—" +
|
||||
max;
|
||||
const sliderValue = answer || currentQuestion.content.start + "—" + max;
|
||||
|
||||
useEffect(() => {
|
||||
if (answer) {
|
||||
@ -86,7 +79,7 @@ export const Number = ({ currentQuestion }: NumberProps) => {
|
||||
}
|
||||
min={min}
|
||||
max={max}
|
||||
step={(max - min) % step ? 1 : step}
|
||||
step={currentQuestion.content.step || 1}
|
||||
onChange={(_, value) => {
|
||||
const range = String(value).replace(",", "—");
|
||||
updateAnswer(currentQuestion.content.id, range);
|
||||
|
Loading…
Reference in New Issue
Block a user