-
Notifications
You must be signed in to change notification settings - Fork 8
fix: Flashing pdf beneath the single invoice #333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Flashing pdf beneath the single invoice #333
Conversation
WalkthroughThe changes refine the PDF generation process in the invoice utility. The Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant F as exportToPDF Function
participant D as Document Body
U->>F: Click "Download PDF"
F->>D: Create and append hidden container (off-screen)
F->>F: Render invoice HTML into hidden container
F->>F: Attempt PDF generation (inside try block)
alt PDF generation succeeds or fails
F->>D: Remove hidden container
end
Assessment against linked issues
Suggested reviewers
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
shared/utils/generateInvoice.ts (1)
217-235
: Consider enhancing error handling and cleanup.The try-finally block ensures proper cleanup, but consider these improvements:
- Add error handling for PDF generation failures
- Clean up any event listeners before removing the container
Apply this diff to enhance error handling:
try { await window .html2pdf() .from(element) .set(opt) .save(); + } catch (error) { + console.error('Failed to generate PDF:', error); + throw error; } finally { if (document.body.contains(container)) { + // Clean up any potential event listeners + const clone = container.cloneNode(true); + container.parentNode?.replaceChild(clone, container); document.body.removeChild(clone); } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
shared/utils/generateInvoice.ts
(3 hunks)
🧰 Additional context used
📓 Learnings (1)
shared/utils/generateInvoice.ts (1)
Learnt from: MantisClone
PR: RequestNetwork/web-components#141
File: packages/invoice-dashboard/src/utils/generateInvoice.ts:0-0
Timestamp: 2024-11-12T14:52:33.204Z
Learning: In `packages/invoice-dashboard/src/utils/generateInvoice.ts`, the `paymentCurrencies` parameter in the `exportToPDF` function is intended to have the type `any[]`.
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (1)
shared/utils/generateInvoice.ts (1)
205-215
: Well-implemented solution to prevent PDF preview flashing!The hidden container implementation effectively addresses the PR objective by:
- Moving the container off-screen using fixed positioning
- Making it invisible with zero height and opacity
- Preventing any user interaction with pointer-events: none
…sh-at-bottom-of-screen-after-clicking-download-pdf-icon
Fixes: #325
Problem
When a user clicks the Download PDF icon on the Single Invoice Page, a preview flash appears at the bottom of the screen. This unexpected flash disrupts the user experience.
Changes
Summary by CodeRabbit
Bug Fixes
Refactor