Skip to content

Commit

Permalink
When starting input with operator, append to existing value instead o…
Browse files Browse the repository at this point in the history
…f replacing
  • Loading branch information
JazzyJosh committed Mar 30, 2024
1 parent 38ffccb commit 97a2dc0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/desktop-client/src/components/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 97a2dc0

Please sign in to comment.