Skip to content

fix(pos): guard shortcut modifiers and close help modal before blurring input - #1127

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

khaira777 merged 3 commits into
mainfrom
fm/flocafe-issue-1070-r1

Conversation

@khaira777

@khaira777 khaira777 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Verify and implement the surgical fix for FreeOpenSourcePOS/FloCafe issue #1070 ("POS keyboard shortcuts trigger on browser/OS modifier combinations and Escape blurs input before closing help"): in frontend/src/hooks/usePosKeyboardShortcuts.ts and frontend/src/app/(dashboard)/pos/page.tsx, prevent Ctrl/Alt/Meta modifier combinations (such as Ctrl+Minus or Option+Digit) from triggering cart quantity or shortcut actions, use physical Digit codes where appropriate, and ensure Escape closes the help overlay before blurring a focused input. Deliver via the no-mistakes pipeline as its own PR with Fixes #1070 in the PR summary.

What Changed

  • Guard POS keyboard shortcuts in usePosKeyboardShortcuts against unintended Ctrl, Meta, Alt, and Shift modifier combinations while matching Alt+2 and Alt+4 via physical Digit2/Digit4 key codes (e.code) so macOS Option chords work reliably.
  • Reorder onDismissModalOrBlur in POSPage so pressing Escape closes the keyboard shortcuts help modal before blurring a focused <input> or <textarea>.
  • Add unit and Playwright E2E coverage for modified key combinations, defaultPrevented behavior, physical Alt+Digit chords, and Escape modal dismissal priority.

Fixes #1070

Risk Assessment

✅ Low: The change is a small, well-bounded keyboard event guard update and Escape dismissal ordering fix with comprehensive unit and E2E behavioral test coverage.

Testing

Ran the targeted unit test suite (npm run test:pos-keyboard-shortcuts), built the backend (npm run build), and executed all 7 Playwright E2E tests in frontend/e2e/pos-keyboard-shortcuts.spec.ts against the live running POS server and Chromium browser, capturing visual screenshot evidence in ~/.no-mistakes/evidence/01M4VJ3X5V5WYW0D87PCQ48VHA; all tests and live scenarios passed.

  • Live validation: ✅ go - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Pressing browser/OS modifier combinations with +/- (Ctrl+Minus, Meta+Minus, Alt+Minus, non-QWERTY Option+Digit6 producing '-') on the POS page does not increment or decrement the cart item quantity, w… ✅ pass live npx playwright test --config=playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts (~/.no-mistakes/evidence/01M4VJ3X5V5WYW0D87PCQ48VHA/keyboard-multiplier-cart…
Pressing macOS Option+2 (where e.key is '™' and e.code is 'Digit2') toggles the table picker modal open and closed via physical Digit code matching, while modified F2 or Option+other digits do not tri… ✅ pass live npx playwright test --config=playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts
When the product search input is focused and the keyboard shortcuts help modal is opened via F1, pressing Escape once closes the help modal while keeping the search input focused, and pressing Escape… ✅ pass live npx playwright test --config=playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts (~/.no-mistakes/evidence/01M4VJ3X5V5WYW0D87PCQ48VHA/keyboard-shortcuts-modal…
Adversarial modifier combinations (Ctrl, Meta, Alt, Shift) on Escape, F1-F11, Space, ?, /, Cmd/Ctrl+K, and Alt+Backspace do not trigger POS shortcut handlers or call preventDefault on browser/OS short… ⏸️ untested no The prior payload did not establish a live result for the full combinatorial modifier matrix across all remaining shortcut handlers (verified via unit tests in tests/pos-keyboard-shortcuts.test.ts rat…

POS Keyboard Shortcuts Modal Cheat Sheet
POS Cart Quantity Adjustment and Multiplier Search State
POS Keyboard Checkout Order Completed State

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ No issues found.

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Cashier adjusts cart quantity with plain + and - keys while browser/OS modifier combinations (Ctrl+Minus, Meta+Minus, Alt+Minus, and Option+Digit emitting '-') do not alter cart quantity ✅ pass live npx --prefix frontend playwright test --config=frontend/playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts ("/ focuses product search input, and multiplier search adds item w…
Cashier toggles the table picker modal open and closed using F2 and macOS Option+2 (physical code Digit2 emitting key '™') ✅ pass live npx --prefix frontend playwright test --config=frontend/playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts ("F2 toggles table picker, and Escape dismisses it")
Cashier opens the keyboard shortcuts modal via F1 while the product search input is focused; pressing Escape once closes the help modal while preserving input focus, and pressing Escape a second time… ✅ pass live npx --prefix frontend playwright test --config=frontend/playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts ("? opens keyboard shortcuts modal cheat sheet, Escape closes it")…
Cashier uses F4 and Space to tender a takeaway order and types shortcut characters (+, -, /, space) inside the search input without triggering global POS actions ✅ pass live npx --prefix frontend playwright test --config=frontend/playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts ("F4 opens checkout modal, and Space tenders cash to complete order…
  • npm run test:pos-keyboard-shortcuts
  • npm run build && npm run build:frontend
  • npx --prefix frontend playwright test --config=frontend/playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts

✅ No issues found.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Pressing F1 while the POS product search input is focused opens the Keyboard Shortcuts help modal, pressing Escape once closes the modal while keeping the search input focused, and pressing Escape a s… ✅ pass live npx playwright test --config=playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts ("? opens keyboard shortcuts modal cheat sheet, Escape closes it") & ~/.no-m…
Adversarial modifier guard: pressing Control+Minus, Meta+Minus, Alt+Minus, or Option+Digit6 emitting "-" while an item is in the POS cart does not decrement the cart item quantity, whereas plain "+" a… ✅ pass live npx playwright test --config=playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts ("/ focuses product search input, and multiplier search adds item with quantity") & ~
Pressing macOS Option+2 (key "™", physical code "Digit2", altKey: true) toggles the POS table picker modal open and closed, while non-Digit2/Digit4 Option combinations or extra modifiers (Ctrl/Meta/Sh… ✅ pass live npx playwright test --config=playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts ("F2 toggles table picker, and Escape dismisses it") & npm run test:pos-keyboard-shortcuts
Plain POS keyboard shortcuts (?, /, F1, F2, F4, Space, Escape) open help, focus search, toggle tables, open checkout, tender cash, and dismiss modals without regression ✅ pass live npx playwright test --config=playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts ("F4 opens checkout modal, and Space tenders cash to complete order") & ~/.n…
  • npm run test:pos-keyboard-shortcuts
  • npm run build && npm run build:frontend
  • cd frontend && npx playwright test --config=playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts

✅ No issues found.

  • Live validation: ✅ go - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Pressing browser/OS modifier combinations with +/- (Ctrl+Minus, Meta+Minus, Alt+Minus, non-QWERTY Option+Digit6 producing '-') on the POS page does not increment or decrement the cart item quantity, w… ✅ pass live npx playwright test --config=playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts (~/.no-mistakes/evidence/01M4VJ3X5V5WYW0D87PCQ48VHA/keyboard-multiplier-cart…
Pressing macOS Option+2 (where e.key is '™' and e.code is 'Digit2') toggles the table picker modal open and closed via physical Digit code matching, while modified F2 or Option+other digits do not tri… ✅ pass live npx playwright test --config=playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts
When the product search input is focused and the keyboard shortcuts help modal is opened via F1, pressing Escape once closes the help modal while keeping the search input focused, and pressing Escape… ✅ pass live npx playwright test --config=playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts (~/.no-mistakes/evidence/01M4VJ3X5V5WYW0D87PCQ48VHA/keyboard-shortcuts-modal…
Adversarial modifier combinations (Ctrl, Meta, Alt, Shift) on Escape, F1-F11, Space, ?, /, Cmd/Ctrl+K, and Alt+Backspace do not trigger POS shortcut handlers or call preventDefault on browser/OS short… ⏸️ untested no The prior payload did not establish a live result for the full combinatorial modifier matrix across all remaining shortcut handlers (verified via unit tests in tests/pos-keyboard-shortcuts.test.ts rat…
  • npm run test:pos-keyboard-shortcuts
  • npm run build
  • npx playwright test --config=playwright.config.ts --project=chromium e2e/pos-keyboard-shortcuts.spec.ts
✅ **Document** - passed

✅ No issues found.

✅ No issues found.

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ No issues found.

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

✅ No issues found.

✅ No issues found.

@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: beb5f27d-33d3-426b-92f8-551fd02f7248

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(frontend): guard POS keyboard shortcuts against modifier collisions fix(pos): guard shortcut modifiers and Escape 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] Adds keyboard shortcut guards to prevent accidental triggers.

The PR appears safe to merge, with a non-blocking gap in function-key regression tests.

Findings

  1. P2 Several key guards lack tests ▶

Summary

This PR prevents modified keys from triggering POS actions, recognizes physical Digit2/Digit4 keys for Option shortcuts, and closes shortcut help before blurring an input.

  • POS shortcuts ignore extra modifiers but keep Option number shortcuts working.
  • Escape closes keyboard help before it blurs a focused input.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Key[Keyboard event] --> Escape{Plain Escape?}
  Escape -->|Yes| Help{Shortcut help open?}
  Help -->|Yes| Close[Close help and keep input focus]
  Help -->|No| Dismiss[Blur input or dismiss another modal]
  Escape -->|No| Guards[Check modifiers, typing, and open modals]
  Guards --> Action[Run matching POS shortcut]
Loading

Reviews (1) · Last reviewed commit: "no-mistakes(review): {"summary":"test(po..." · Reviewed by Greptile

Comment thread tests/pos-keyboard-shortcuts.test.ts Resolved
@khaira777

Copy link
Copy Markdown
Contributor Author

The production changes look sound, but the new modifier guards need stronger regression coverage before merging.

The tests cover quantity shortcuts and macOS Option+Digit behavior, but several changed guards remain untested.

Please:

  1. Add table-driven unit tests for Escape, F1, F11, F2, F3, F6, and F8.
  2. Verify that each supported plain shortcut still calls the expected handler.
  3. Verify that unsupported Ctrl, Meta, Alt, and Shift combinations do not trigger POS actions.
  4. Check both handler call counts and defaultPrevented, so native browser or OS shortcuts are not blocked when they should pass through.
  5. Preserve the intentional Alt+2 and Alt+4 behavior, including macOS physical Digit key codes.
  6. Keep the browser test verifying that Escape closes the keyboard shortcuts help modal before blurring the background input.
  7. Run the focused unit and Playwright tests and confirm they pass.

Do not change production shortcut behavior unless a failing test reveals a real issue. Keep the fix limited to missing coverage and any confirmed defects. Avoid unrelated refactoring or formatting.

@khaira777
khaira777 force-pushed the fm/flocafe-issue-1070-r1 branch from a8f252b to b47c89b Compare October 13, 2026 21:28
@khaira777 khaira777 changed the title fix(pos): guard shortcut modifiers and Escape fix(pos): guard keyboard shortcut modifiers and Escape help dismissal Oct 13, 2026
@khaira777 khaira777 changed the title fix(pos): guard keyboard shortcut modifiers and Escape help dismissal fix(pos): block shortcuts when modal open Oct 13, 2026
@khaira777
khaira777 force-pushed the fm/flocafe-issue-1070-r1 branch from b47c89b to a2d8aca Compare October 13, 2026 22:41
@khaira777 khaira777 changed the title fix(pos): block shortcuts when modal open fix(pos): guard keyboard shortcuts against modifier chords and close help before blurring input Oct 13, 2026
@khaira777
khaira777 force-pushed the fm/flocafe-issue-1070-r1 branch from a2d8aca to 3291786 Compare October 13, 2026 23:37
@khaira777 khaira777 changed the title fix(pos): guard keyboard shortcuts against modifier chords and close help before blurring input fix(pos): guard shortcut modifiers and close help modal before blurring input Oct 13, 2026
Prevent Ctrl/Alt/Meta modifier combinations from triggering POS cart quantity or single-key shortcuts, use physical Digit2/Digit4 codes for Alt/Option shortcuts, and dismiss the keyboard shortcuts help modal on Escape before blurring a focused input.

Fixes #1070
@khaira777
khaira777 force-pushed the fm/flocafe-issue-1070-r1 branch from 3291786 to 72e5028 Compare October 13, 2026 23:43
@khaira777
khaira777 enabled auto-merge (squash) October 13, 2026 23:43
@khaira777
khaira777 merged commit 66909aa into main Oct 13, 2026
23 checks passed
@khaira777
khaira777 deleted the fm/flocafe-issue-1070-r1 branch October 13, 2026 23:52
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): address keyboard shortcut conflicts with browser zoom and macOS Option keys

1 participant