Skip to content
Snippets Groups Projects
Unverified Commit a955fe24 authored by Joshua Harris's avatar Joshua Harris Committed by GitHub
Browse files

When starting input with operator, append to existing value instead of replacing (#2523)

parent 4e9130ac
No related branches found
No related tags found
No related merge requests found
......@@ -339,11 +339,25 @@ function InputValue({
}
}
const ops = ['+', '-', '*', '/', '^'];
function valueIsASingleOperator(text) {
return text?.length === 1 && ops.includes(text.charAt(0));
}
function setValue_(text) {
if (valueIsASingleOperator(text)) {
setValue(defaultValue + text);
} else {
setValue(text);
}
}
return (
<Input
{...props}
value={value}
onChangeValue={text => setValue(text)}
onChangeValue={text => setValue_(text)}
onBlur={onBlur_}
onUpdate={onUpdate}
onKeyDown={onKeyDown}
......
---
category: Enhancements
authors: [JazzyJosh]
---
Using any math operator on an input will begin a calculation starting with the existing value.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment