Skip to content

fix(pos): ignore repeated checkout confirmation - #1117

Merged
khaira777 merged 2 commits into
mainfrom
fm/flocafe-issue-1066-r1
Oct 13, 2026
Merged

khaira777 merged 2 commits into
mainfrom
fm/flocafe-issue-1066-r1

Conversation

@khaira777

@khaira777 khaira777 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1066

Intent

Implement the surgical fix for FreeOpenSourcePOS/FloCafe issue #1066 ("Holding Space bar auto-confirms checkout"): guard repeated keydown events (e.repeat) after e.preventDefault() on the Space/tender branch in frontend/src/hooks/usePosKeyboardShortcuts.ts and on the Space/Enter confirmation branch in frontend/src/components/pos/PrepaidCheckoutModal.tsx so holding Space to open checkout cannot auto-confirm payment without a deliberate second press. Deliver via the no-mistakes pipeline as its own PR (Fixes #1066).

What Changed

  • Guard repeated keydown events (e.repeat) after e.preventDefault() on the Space tender handler in usePosKeyboardShortcuts and on the Space/Enter confirmation handler in PrepaidCheckoutModal, requiring a fresh key press to confirm payment.
  • Add unit tests in tests/pos-keyboard-shortcuts.test.ts and browser E2E tests in frontend/e2e/pos-keyboard-shortcuts.spec.ts covering repeated Space/Enter events, typing-target and button immunity, and initial vs. repeated key presses.

Risk Assessment

✅ Low: The change is a minimal, well-bounded two-line guard on repeated keydown events after preventDefault() in the POS keyboard shortcut hook and prepaid checkout modal, backed by unit and E2E behavioral regression tests.

Testing

Ran npm run test:pos-keyboard-shortcuts, built the backend and static frontend (npm run build && npm run build:frontend), executed all 6 Playwright E2E tests in frontend/e2e/pos-keyboard-shortcuts.spec.ts against an isolated live FloCafe instance, and captured visual screenshots plus JSON telemetry proving that repeated Space and Enter keydown events (e.repeat === true) call preventDefault() without opening or auto-confirming checkout, while a fresh non-repeat Space or Enter press after key release settles the order once.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
A cashier sends a repeated Space keydown (e.repeat = true) on the POS canvas with items in cart; default scrolling is prevented and the prepaid checkout modal does not open until an initial non-repe… ✅ pass live `E2E_BASE_URL=http://127.0.0.1:43101 E2E_KDS_BASE_URL=http://127.0.0.1:43102 E2E_SERVER_APP_BASE_URL=http://127.0.0.1:43103 npx playwright test --config=playwright.config.ts --project=chromium e2e/pos…
Adversarial hold/auto-repeat guard: holding Space across checkout modal mount and tax preview settlement (or holding Enter while the Confirm Payment button is focused) prevents default on every repeat… ✅ pass live ~/.no-mistakes/evidence/01M4VGR470XCCGWQCXT3B54G9H/issue-1066-modal-remains-open-on-repeat-space-enter.png and `~/.no-mistakes/evidence/01M4VGR470XCCGWQCXT3B5…
After releasing the held key (keyup), pressing a fresh non-repeat Space or Enter inside the prepaid checkout modal confirms payment exactly once, closes the modal, clears the cart, and increments pa… ✅ pass live ~/.no-mistakes/evidence/01M4VGR470XCCGWQCXT3B54G9H/issue-1066-order-settled-after-fresh-space.png and e2e/pos-keyboard-shortcuts.spec.ts
Existing POS keyboard shortcuts (/ search focus, +/- quantity adjustments including key repeat, F2 table picker, F4 checkout, ? help modal, and typing immunity in inputs/buttons) continue… ✅ pass live npm run test:pos-keyboard-shortcuts and e2e/pos-keyboard-shortcuts.spec.ts

Prepaid checkout modal remains open during repeated Space and Enter keydown events (0 orders/payments sent)
Order settled and cart cleared only after releasing Space and pressing a deliberate fresh Space

Evidence: Live browser keyboard event and network request verification summary (JSON)

{"repeatCanvasPrevented":true,"modalVisibleOnCanvasRepeat":false,"repeatSpacePrevented":true,"repeatEnterPrevented":true,"modalStillVisibleAfterRepeats":true,"ordersAfterRepeats":0,"paymentsAfterRepeats":0,"ordersAfterFreshSpace":1,"paymentsAfterFreshSpace":1}

{
  "repeatCanvasPrevented": true,
  "modalVisibleOnCanvasRepeat": false,
  "repeatSpacePrevented": true,
  "repeatEnterPrevented": true,
  "modalStillVisibleAfterRepeats": true,
  "ordersAfterRepeats": 0,
  "paymentsAfterRepeats": 0,
  "ordersAfterFreshSpace": 1,
  "paymentsAfterFreshSpace": 1
}

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
A cashier sends a repeated Space keydown (e.repeat = true) on the POS canvas with items in cart; default scrolling is prevented and the prepaid checkout modal does not open until an initial non-repe… ✅ pass live `E2E_BASE_URL=http://127.0.0.1:43101 E2E_KDS_BASE_URL=http://127.0.0.1:43102 E2E_SERVER_APP_BASE_URL=http://127.0.0.1:43103 npx playwright test --config=playwright.config.ts --project=chromium e2e/pos…
Adversarial hold/auto-repeat guard: holding Space across checkout modal mount and tax preview settlement (or holding Enter while the Confirm Payment button is focused) prevents default on every repeat… ✅ pass live ~/.no-mistakes/evidence/01M4VGR470XCCGWQCXT3B54G9H/issue-1066-modal-remains-open-on-repeat-space-enter.png and `~/.no-mistakes/evidence/01M4VGR470XCCGWQCXT3B5…
After releasing the held key (keyup), pressing a fresh non-repeat Space or Enter inside the prepaid checkout modal confirms payment exactly once, closes the modal, clears the cart, and increments pa… ✅ pass live ~/.no-mistakes/evidence/01M4VGR470XCCGWQCXT3B54G9H/issue-1066-order-settled-after-fresh-space.png and e2e/pos-keyboard-shortcuts.spec.ts
Existing POS keyboard shortcuts (/ search focus, +/- quantity adjustments including key repeat, F2 table picker, F4 checkout, ? help modal, and typing immunity in inputs/buttons) continue… ✅ pass live npm run test:pos-keyboard-shortcuts and e2e/pos-keyboard-shortcuts.spec.ts
  • npm run test:pos-keyboard-shortcuts
  • npm run build && npm run build:frontend
  • E2E_BASE_URL=http://127.0.0.1:43101 E2E_KDS_BASE_URL=http://127.0.0.1:43102 E2E_SERVER_APP_BASE_URL=http://127.0.0.1:43103 npx playwright test --config=playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts
  • Live Chromium verification script against tests/e2e-server.cjs on isolated ports 43201/43202/43203 capturing screenshots and JSON telemetry in ~/.no-mistakes/evidence/01M4VGR470XCCGWQCXT3B54G9H
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@khaira777 khaira777 changed the title fix(frontend): ignore repeated keydown events on POS tender and checkout confirmation fix(pos): ignore repeated checkout confirmation Oct 13, 2026
@FreeOpenSourcePOS FreeOpenSourcePOS deleted a comment from coderabbitai Bot Oct 13, 2026
@khaira777

Copy link
Copy Markdown
Contributor Author

@greptile review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium impact] Point-of-sale keyboard handling prevents accidental repeated confirmations.

The production fix appears safe to merge, with a non-blocking correction needed in the browser test's bill-count checks.

Findings

  1. P2 Bill counts stop at 50 ▶

Summary

Stops held checkout keys from confirming payment:

  • Held Space and Enter presses no longer advance checkout repeatedly.

The production fix preserves existing checks. The browser test should use the full paid-bill count rather than the length of one page. This review inspected code only; it did not run tests.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Space on POS canvas] --> B[Prevent default]
  B --> C{Repeated keydown?}
  C -->|Yes| D[Ignore]
  C -->|No| E[Open checkout]
  E --> F[Space or Enter in checkout]
  F --> G[Prevent default]
  G --> H{Repeated keydown?}
  H -->|Yes| D
  H -->|No| I[Run existing payment checks]
  I --> J[Confirm payment]
Loading

Reviews (1) · Last reviewed commit: "fix(pos): ignore repeated checkout confi..." · Reviewed by Greptile

@khaira777

Copy link
Copy Markdown
Contributor Author

The production fix looks good, but the remaining Greptile finding needs to be addressed before merging.

  • In frontend/e2e/pos-keyboard-shortcuts.spec.ts, the new tests count bills using bills.length. The API returns at most 50 bills per page, so these checks can fail when the database contains enough bills.
  • Update all four bill-count snapshots to use pagination.total instead.
  • Keep the tests verifying that holding Space or Enter cannot confirm a payment, while a fresh key press can confirm it once.
  • Run the affected tests and confirm they pass.

Please keep the changes focused on the test issue. No unrelated formatting or refactoring.

@khaira777
khaira777 force-pushed the fm/flocafe-issue-1066-r1 branch from d399d9d to ef193aa Compare October 13, 2026 21:06
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: FreeOpenSourcePOS/FloCafe/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ddc75cb1-f49b-47ba-8072-dfb3c79cc973

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@khaira777 khaira777 changed the title fix(pos): ignore repeated checkout confirmation fix(pos): ignore repeated keydown events during checkout Oct 13, 2026
@khaira777 khaira777 changed the title fix(pos): ignore repeated keydown events during checkout fix(pos): ignore repeated checkout confirmation Oct 13, 2026
Guard repeated keydown events (e.repeat) after preventDefault() on the POS canvas Space tender branch and the PrepaidCheckoutModal Space/Enter confirmation branch so holding Space to open checkout cannot auto-confirm payment without a deliberate second press.

Fixes #1066
@khaira777
khaira777 force-pushed the fm/flocafe-issue-1066-r1 branch from ef193aa to 6877806 Compare October 13, 2026 22:18
@khaira777
khaira777 enabled auto-merge (squash) October 13, 2026 22:18
@khaira777
khaira777 merged commit 0b3d909 into main Oct 13, 2026
23 checks passed
@khaira777
khaira777 deleted the fm/flocafe-issue-1066-r1 branch October 13, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(pos): ignore keyboard auto-repeat for checkout modal tender accelerator

1 participant