Repository navigation
fix(staff): close staff modal on Escape key - #1136
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
|
@greptile review |
|
|
The Escape handler correctly closes the Add Staff and Edit Staff modals, and the listener cleanup looks sound. However, I found additional gaps when checking the Staff page and the linked issue's accessibility requirements. Please address these before merging:
Reuse existing modal or focus-management patterns where practical. Keep the implementation focused on Staff modal keyboard behavior, preserve all existing form and password-reset functionality, and run the relevant unit and Playwright tests. Please report the results before merging. No unrelated changes or refactoring. |
7a0031c to
9911962
Compare
Register a window keydown listener while the Staff create/edit modal is open so pressing Escape closes the modal via closeForm(). Fixes #1098
9911962 to
3e0a6fc
Compare
Fixes #1098
Intent
Verify and implement the surgical fix for FreeOpenSourcePOS/FloCafe issue #1098 ("Staff modal dialog does not close on Escape key"): in
frontend/src/app/(dashboard)/staff/page.tsx, handleEscapekey presses while the Staff create/edit modal is open so pressingEscapecloses the modal cleanly. Deliver via theno-mistakespipeline as its own PR withFixes #1098in the PR summary.Address all review comments on PR #1136 before merging:
showResetPw, but the new Escape listener only handlesshowForm. Make sure Escape also closes the Reset Password modal, without changing its password-reset behavior.#1098reference and redundant step-description comments fromtests/auth-ui-deterministic.test.tsto comply withAGENTS.md.What Changed
keydownlistener infrontend/src/app/(dashboard)/staff/page.tsxwhile the create/edit Staff modal (showForm) or Reset Password modal (showResetPw) is open so pressingEscapecloses the active dialog and cleans up the listener.role="dialog",aria-modal="true", andaria-labelledby="reset-password-modal-title"to the Reset Password modal container.tests/auth-ui-deterministic.test.tsand Playwright E2E coverage infrontend/e2e/layout-integrity.spec.tsverifyingEscapedismissal, non-Escapekey preservation, trigger focus restoration, and listener cleanup across repeated modal open/close cycles.Fixes #1098
Risk Assessment
✅ Low: The change is a small, well-bounded UI update that closes the Staff and Reset Password modals on Escape, restores focus to the originating trigger button, and covers the behavior in deterministic and browser E2E tests.
Testing
Ran the deterministic auth/staff UI test suite (
npm run test:auth-ui-deterministic), built the backend and static frontend (npm run build && npm run build:frontend), executed the Playwright browser E2E test (e2e/layout-integrity.spec.ts -g "staff modals close on Escape"), and drove a live Chromium session againsttests/e2e-server.cjsto capture visual screenshots and verify focus restoration, listener cleanup, and Reset PasswordPUT /api/staff/:idsubmission; all checks and scenarios passed.npx playwright test --config=playwright.config.ts --project=chromium e2e/layout-integrity.spec.ts -g "staff modals close on Escape"and `~/.no-mistakes/evidence/01M4W2AJ4KFGMH9TT…npx playwright test --config=playwright.config.ts --project=chromium e2e/layout-integrity.spec.ts -g "staff modals close on Escape"and `~/.no-mistakes/evidence/01M4W2AJ4KFGMH9TT…npx playwright test --config=playwright.config.ts --project=chromium e2e/layout-integrity.spec.ts -g "staff modals close on Escape", `~/.no-mistakes/evidence/01M4W2AJ4KFGMH9TTC9R…npx playwright test --config=playwright.config.ts --project=chromium e2e/layout-integrity.spec.ts -g "staff modals close on Escape"and `~/.no-mistakes/evidence/01M4W2AJ4KFGMH9TT…npx playwright test --config=playwright.config.ts --project=chromium e2e/layout-integrity.spec.ts -g "staff modals close on Escape",npm run test:auth-ui-deterministic, and `~/…Evidence: Live Playwright focus restoration, listener count, and Reset Password submission verification
{ "baselineListeners": 2, "finalListeners": 2, "focusAfterAdd": { "tag": "BUTTON", "text": "Add Staff" }, "focusAfterEdit": { "tag": "BUTTON", "text": "Edit" }, "focusAfterResetEscape": { "tag": "BUTTON", "text": "Reset PW" }, "focusAfterResetSubmit": { "tag": "BUTTON", "text": "Reset PW" }, "resetPasswordPutStatus": 200 }Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
🔧 **Rebase** - 1 issue found → auto-fixed ✅
frontend/src/app/(dashboard)/staff/page.tsx- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
npx playwright test --config=playwright.config.ts --project=chromium e2e/layout-integrity.spec.ts -g "staff modals close on Escape"and `~/.no-mistakes/evidence/01M4W2AJ4KFGMH9TT…npx playwright test --config=playwright.config.ts --project=chromium e2e/layout-integrity.spec.ts -g "staff modals close on Escape"and `~/.no-mistakes/evidence/01M4W2AJ4KFGMH9TT…npx playwright test --config=playwright.config.ts --project=chromium e2e/layout-integrity.spec.ts -g "staff modals close on Escape", `~/.no-mistakes/evidence/01M4W2AJ4KFGMH9TTC9R…npx playwright test --config=playwright.config.ts --project=chromium e2e/layout-integrity.spec.ts -g "staff modals close on Escape"and `~/.no-mistakes/evidence/01M4W2AJ4KFGMH9TT…npx playwright test --config=playwright.config.ts --project=chromium e2e/layout-integrity.spec.ts -g "staff modals close on Escape",npm run test:auth-ui-deterministic, and `~/…npm run test:auth-ui-deterministicnpm run build && npm run build:frontendnpx playwright test --config=playwright.config.ts --project=chromium e2e/layout-integrity.spec.ts -g "staff modals close on Escape"node -e "...live Playwright verification with screenshots and Reset Password PUT check against tests/e2e-server.cjs..."✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.