From 97a2dc00462fd4b5578da8bad42ae98062f5d06d Mon Sep 17 00:00:00 2001 From: Joshua Harris <2312397+JazzyJosh@users.noreply.github.com> Date: Mon, 25 Mar 2024 23:27:09 -0400 Subject: [PATCH] When starting input with operator, append to existing value instead of replacing --- packages/desktop-client/src/components/table.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/desktop-client/src/components/table.tsx b/packages/desktop-client/src/components/table.tsx index 59ff2f19565..96fd84131b6 100644 --- a/packages/desktop-client/src/components/table.tsx +++ b/packages/desktop-client/src/components/table.tsx @@ -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 ( setValue(text)} + onChangeValue={text => setValue_(text)} onBlur={onBlur_} onUpdate={onUpdate} onKeyDown={onKeyDown}