Skip to content
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(DEV-11506): prevent incorrect rendering of images in <FileViewer /> 😶‍🌫️ #133

Merged
merged 3 commits into from
Jul 1, 2024

Conversation

radist2s
Copy link
Contributor

@radist2s radist2s commented Jun 30, 2024

Problem

When an image was selected instead of a PDF for an invoice, the PDFObject.embed() function was still being called, even though the PDF container wasn't rendered. This caused the entire page content to be replaced with the image inside an iframe, as the ref wasn't properly set.

Solution

We've refactored the FileViewer component to correctly handle different file types, particularly distinguishing between PDFs and images.

Changes

  • Added a check to prevent PDFObject.embed() calls for non-PDF files
  • Implemented separate rendering logic for PDFs and images:
    • For PDFs: Use PDFFileViewer component
    • For images: Render a simple <img /> tag with appropriate styling

Impact

  • Prevents unintended page content replacement when viewing non-PDF files
  • Simplifies the codebase by removing redundant conditional checks

Testing

Please test the following scenarios:

  1. Uploading and viewing PDF files for invoices
  2. Uploading and viewing image files for invoices
  3. Switching between PDF invoice and image file invoice to ensure correct rendering
  4. Checking that the page layout remains intact when viewing non-PDF files

Copy link

changeset-bot bot commented Jun 30, 2024

🦋 Changeset detected

Latest commit: 84ebfff

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@monite/sdk-react Patch
@team-monite/sdk-demo Patch
@monite/sdk-drop-in Patch
@monite/sdk-api Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@radist2s radist2s changed the title fix(DEV-11506): file viewer issue fix(DEV-11506): prevent incorrect rendering of images in <FileViewer /> Jun 30, 2024
@radist2s radist2s requested review from vkuprin and nekedos June 30, 2024 01:23
@radist2s radist2s marked this pull request as ready for review June 30, 2024 01:23
@radist2s radist2s changed the title fix(DEV-11506): prevent incorrect rendering of images in <FileViewer /> fix(DEV-11506): prevent incorrect rendering of images in <FileViewer /> 😶‍🌫️ Jun 30, 2024
@radist2s radist2s changed the base branch from dev to main June 30, 2024 01:32
@radist2s radist2s changed the base branch from main to dev June 30, 2024 01:33
@radist2s radist2s force-pushed the fix/DEV-11506-file-viewer-issue branch from f904090 to 84ebfff Compare June 30, 2024 11:41
@radist2s radist2s changed the base branch from dev to main July 1, 2024 08:41
@radist2s radist2s merged commit 405e2c6 into main Jul 1, 2024
14 checks passed
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.

3 participants