Typing "-" in a cell is silently dropped: "500-120" is saved as 500120

Open Beginner friendly
#170 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript

Research direction

Start with src/app/components/base/currency-cell/CurrencyCell.vue and inspect the keydown handler that blocks -. Run the “Evaluate expressions correctly” scenario in test/budgets.spec.ts, changing keyboard input to pressSequentially() to reproduce the real interaction. Done means typing 500-120 evaluates to 380 or is marked invalid, with a regression test covering keyboard entry.

Written by the indexing model from the issue text.

Description

bug
I've found a bug and checked that ...
  • ...there are no open or closed issues that are related to my problem
  • ...it's definitely a bug and not a feature request
Description

The expression evaluator supports subtraction, but CurrencyCell.vue calls preventDefault() on every - keydown. When a user types 500-120 on the keyboard, the minus is swallowed and the cell silently stores 500120 instead of 380. The input is not marked invalid, so the wrong amount goes unnoticed. Pasting 500-120 works correctly (380).

Related but different: #165 (allow negative numbers) and #144 (subtract in cells). This issue is about silent data corruption, not about the feature.

Environment
  • Browser: Chromium-based
  • OS: Windows 10
  • Ocular version: main at 3cb23f7 (2026-09-05), pnpm dev
Expected behaviour

Either 500-120 evaluates to 380, or the cell is marked invalid. It should never store a different number than the one the user typed.

Steps to reproduce
  1. Open Income and click any cell.
  2. Type 500-120 on the keyboard, then press Enter or click outside.
  3. The cell shows 500,120 instead of 380.
Additional info
  • Cause: src/app/components/base/currency-cell/CurrencyCell.vue, the keydown handler blocks - unconditionally.
  • The e2e test "Evaluate expressions correctly" (test/budgets.spec.ts) fills 500 - 50 with fill(). That sets the value directly and never fires keydown, so the test passes while real keyboard input fails. Using pressSequentially() reproduces the bug.
  • Possible fix: allow - everywhere except the first character, or drop the keydown block and let validation reject negative results. Also switch that test to pressSequentially().
Dominant language
Vue
Stars
565
Forks
44
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from simonwep/ocular

All issues in simonwep/ocular

Similar issues

More Web Dev issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.