Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions ui/src/spinbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,30 @@ export const
const [head, tail = ''] = val.split('.')
setVal(`${head}.${tail.slice(0, precision)}`)
}
else setVal(String(newValue))
return newValue
else {
// Check if the value is in scientific notation
if (isScientific) {
// If the value is in scientific notation, check if it's within the specified range
if (numericValue < 1e-4 || numericValue > 1e6) {
// If it's not within the range, transform the value into decimal
const decimalValue = scientificToDecimal(numericValue);
setVal(decimalValue);
return decimalValue;
}
} else {
// If the value is in decimal notation, check if it's within the specified range
if (numericValue < 1e-4 || numericValue > 1e6) {
// If it's not within the range, transform the value into scientific notation
const scientificValue = numericValue.toExponential();
setVal(scientificValue);
return scientificValue;
}
}

// If the value is within the specified range or not in scientific notation, keep the original value
setVal(val);
}
return newValue
}, [max, min, parseValue, precision]),
handleOnInput = React.useCallback((val: U) => {
wave.args[name] = val
Expand Down Expand Up @@ -148,4 +170,4 @@ export const
disabled={disabled}
/>
)
}
}