Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
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
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
6 changes: 6 additions & 0 deletions upcoming-release-notes/2523.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [JazzyJosh]
---

Using any math operator on an input will begin a calculation starting with the existing value.
Loading