Repository navigation
fix(print): keep menu popup open until print - #1380
Merged
Merged
Conversation
Attach the menu popup load listener after navigating to the blob URL, invoke focus() and print() once the menu document loads, and only revoke the blob URL and close the popup on afterprint. In PrintMenuModal, keep reservedWindow open when printMenuInBrowser takes ownership and close it only when browser printing does not start. Fixes #1369
Contributor
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1369
Intent
Fix the P1 release-readiness regression from PR #1352 (#1352) at frontend/src/lib/printer/menu-web-print.ts:120 and frontend/src/components/products/PrintMenuModal.tsx:355-374: preserve the popup until menu printing completes. Currently the load listener in printMenuInBrowser is attached before navigating to a new document and does not reliably invoke printing after navigation, and PrintMenuModal immediately closes reservedWindow in its finally block right after printOnPaper or savePdf returns synchronously, before the navigated document loads and prints. Preserve the popup until menu printing completes and invoke focus() and print() after the menu document loads.
What Changed
printMenuInBrowserinfrontend/src/lib/printer/menu-web-print.tsto navigate the popup window to the menu blob URL before tracking document load readiness, invokefocus()andprint()once the navigated menu document finishes loading, and revoke the blob URL and close the window onafterprintor error cleanup.PrintMenuModalinfrontend/src/components/products/PrintMenuModal.tsxto track when a reserved popup window is handed off toprintMenuInBrowseracross paper, PDF browser fallback, and receipt thermal fallback paths so thefinallyblock only closesreservedWindowwhen browser printing did not take ownership.tests/menu-printing.test.tsverifying post-navigationfocus()/print()ordering,afterprintcleanup, andreservedWindowpreservation or closure across all print destinations and failure paths.Risk Assessment
✅ Low: The change is well-bounded to the browser menu print popup lifecycle in menu-web-print.ts and PrintMenuModal.tsx, directly addressing the regression from PR #1352 with behavioral unit tests covering paper, PDF fallback, receipt fallback, and error/empty-catalog cleanup paths.
Testing
Ran npm run test:script-coverage and npm run test:menu-printing (all 13 unit/integration tests passing), built the backend and static frontend, ran the existing Playwright e2e/menu-printing.spec.ts suite, and drove all five popup-lifecycle scenarios live in Chromium against tests/e2e-server.cjs without stubbing window.close while capturing eight visual screenshot artifacts.
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.
npm run test:script-coveragenpm run test:menu-printingnpm run build && npm run build:frontendcd frontend && E2E_BASE_URL=http://127.0.0.1:43001 E2E_KDS_BASE_URL=http://127.0.0.1:43002 E2E_SERVER_APP_BASE_URL=http://127.0.0.1:43003 FLO_E2E_EVIDENCE_DIR=~/.no-mistakes/evidence/01M5WHPBM6JXYZEG0ZCF41SQMP npx playwright test --config=playwright.config.ts --project=chromium e2e/menu-printing.spec.tsLive Playwright Chromium verification against tests/e2e-server.cjs (without stubbing window.close) exercising Paper print, Save as PDF browser fallback, Receipt 502 fallback to browser printing, unused reservedWindow cleanup on empty catalog and direct thermal success, and MenuPopupBlockedError toast handling✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.