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

[HOLD for payment 2024-05-09] [$250] Chat - PDF is displayed closer to the top #37724

Closed
2 of 6 tasks
izarutskaya opened this issue Mar 5, 2024 · 43 comments
Closed
2 of 6 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@izarutskaya
Copy link

izarutskaya commented Mar 5, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v1.4.47-0
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): vdargentotest+mweb030424@gmail.com
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal Team

Action Performed:

Pre-requisite: the user must be logged in.

  1. Go to any chat.
  2. Send the attached PDF.
  3. Tap on the PDF preview to open it.
  4. Verify it is displayed closer to the top.

Expected Result:

The PDF should be displayed in the middle of the viewer section.

Actual Result:

The PDF is displayed closer to the top.

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6402389_1709617684018!pdf.pdf
Bug6402389_1709617667265!IMG_3255

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~012ce46bd1a9c35b0c
  • Upwork Job ID: 1767225873928306688
  • Last Price Increase: 2024-03-18
  • Automatic offers:
    • mollfpr | Reviewer | 0
    • abzokhattab | Contributor | 0
@izarutskaya izarutskaya added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Mar 5, 2024
Copy link

melvin-bot bot commented Mar 5, 2024

Triggered auto assignment to @sakluger (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@izarutskaya
Copy link
Author

@sakluger I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors.

@sakluger
Copy link
Contributor

sakluger commented Mar 5, 2024

@Expensify/design this is a bug, right? I assume we want images to be vertically center-aligned.

@shawnborton
Copy link
Contributor

Hmm I'm not entirely sure... it's a PDF, and I think I would expect viewing a document to be aligned to the top. Curious what others think though.

@shawnborton
Copy link
Contributor

@izarutskaya can you help us understand why you decided that this was a bug?

@dannymcclain
Copy link
Contributor

I'm honestly not sure about this one. It looks like if a PDF will fit in the viewport, we center it. If it's too long, we align it to the top and let you scroll to see the whole thing?

@shawnborton
Copy link
Contributor

Yeah that's fair... this is also a super tricky PDF because the PDF itself is cropped:
CleanShot 2024-03-05 at 11 33 57@2x

@dannymcclain
Copy link
Contributor

Here's a screenshot of that attachment from the app. I feel like this is how we'd expect it to display.

Screenshot 2024-03-05 at 10 37 27 AM

@shawnborton
Copy link
Contributor

Yeah, that makes sense to me. So it seems like this is just an mWeb thing?

@dannymcclain
Copy link
Contributor

Yeah that's what it looks like to me.

@melvin-bot melvin-bot bot added the Overdue label Mar 7, 2024
@sakluger
Copy link
Contributor

sakluger commented Mar 8, 2024

@shawnborton @dannymcclain, just to confirm, are you saying that this is an mWeb bug, or that it's expected mWeb behavior?

@melvin-bot melvin-bot bot removed the Overdue label Mar 8, 2024
@shawnborton
Copy link
Contributor

Yup, seems like an mWeb bug.

@melvin-bot melvin-bot bot added the Overdue label Mar 11, 2024
@sakluger
Copy link
Contributor

Thanks Shawn! I'll mark as external and add to #vip-vsb. I'm going to set the price at $250 since this is just an alignment issue on a single platform.

@melvin-bot melvin-bot bot removed the Overdue label Mar 11, 2024
@sakluger sakluger added the External Added to denote the issue can be worked on by a contributor label Mar 11, 2024
@melvin-bot melvin-bot bot changed the title Chat - PDF is displayed closer to the top [$500] Chat - PDF is displayed closer to the top Mar 11, 2024
Copy link

melvin-bot bot commented Mar 11, 2024

Job added to Upwork: https://www.upwork.com/jobs/~012ce46bd1a9c35b0c

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 11, 2024
Copy link

melvin-bot bot commented Mar 11, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @mollfpr (External)

@sakluger sakluger changed the title [$500] Chat - PDF is displayed closer to the top [$250] Chat - PDF is displayed closer to the top Mar 11, 2024
Copy link

melvin-bot bot commented Mar 11, 2024

Upwork job price has been updated to $250

@abzokhattab
Copy link
Contributor

abzokhattab commented Mar 11, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

PDF is aligned to the top in mWeb

What is the root cause of that problem?

the VariableSizeList component that is provided by the react-window library is used in web platforms to display the PDF.
this component always returns the top padding (style.top) as zero here:

const WebPDFPageRenderer = memo(
({index: pageIndex, data, style}) => {
const {pageWidth, calculatePageHeight, getDevicePixelRatio, estimatedItemSize} = data;
const pageHeight = calculatePageHeight(pageIndex);
const devicePixelRatio = getDevicePixelRatio(pageWidth, pageHeight);
return (
<View style={{...style, top: `${parseFloat(style.top) + PDFViewConstants.PAGE_BORDER}px`}}>
<Page
key={`page_${pageIndex}`}
width={pageWidth}

What changes do you think we should make in order to solve the problem?

we need to use the parent container height and the pdf height to decide the top padding because the default offset provided by the library is 0

also we need to keep the current behaviour for muliple pages pdfs, since there is no/small offset on the native device

to acheive that:

  1. we need to add the containerHeight and the numPages to the itemData prop in the List component:
    itemData={{pageWidth, calculatePageHeight, getDevicePixelRatio, estimatedItemSize}}
  2. then we can access them in the WebPDFPageRenderer by extracting it from the data component:
        const {pageWidth, calculatePageHeight, getDevicePixelRatio, estimatedItemSize, numPages, containerHeight} = data;
  1. then we modify the top padding to:
        const topPadding = numPages > 1 ? parseFloat(style.top) + PDFViewConstants.PAGE_BORDER : parseFloat((containerHeight - style.height) / 2);
        return (
            <View style={{...style, top: `${topPadding}px`}}>

Result

Screen.Recording.2024-03-16.at.6.03.13.AM.mov

@melvin-bot melvin-bot bot added the Overdue label Mar 13, 2024
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Mar 23, 2024
@abzokhattab
Copy link
Contributor

The PR is ready! please check it out and let me know if you have any comments.

@parasharrajat
Copy link
Member

@mollfpr Could you please review #40289?

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels May 2, 2024
@melvin-bot melvin-bot bot changed the title [$250] Chat - PDF is displayed closer to the top [HOLD for payment 2024-05-09] [$250] Chat - PDF is displayed closer to the top May 2, 2024
Copy link

melvin-bot bot commented May 2, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 2, 2024
Copy link

melvin-bot bot commented May 2, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.69-2 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-05-09. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented May 2, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@mollfpr] The PR that introduced the bug has been identified. Link to the PR:
  • [@mollfpr] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@mollfpr] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@mollfpr] Determine if we should create a regression test for this bug.
  • [@mollfpr] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@sakluger] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels May 8, 2024
@Beamanator
Copy link
Contributor

Looks like payment is due here, yeah? No regressions i believe?

@sakluger
Copy link
Contributor

sakluger commented May 9, 2024

Summarizing payment on this issue:

Contributor: @abzokhattab $250, paid via Upwork
Contributor+: @mollfpr $250, please request on Newdot

@melvin-bot melvin-bot bot removed the Overdue label May 9, 2024
@sakluger
Copy link
Contributor

sakluger commented May 9, 2024

@mollfpr could you also please complete the BZ checklist?

@mollfpr
Copy link
Contributor

mollfpr commented May 10, 2024

[@mollfpr] The PR that introduced the bug has been identified. Link to the PR:
[@mollfpr] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:

No offending PR.

[@mollfpr] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:

The regression step should be enough.

[@mollfpr] Determine if we should create a regression test for this bug.
[@mollfpr] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

  1. Go to any chat.
  2. Upload two single-page PDFs: one with a long page and another with a short page.
  3. Click on the PDF preview to open each document.
  4. Ensure that both PDFs are centered properly. Check that the longer PDF displays correctly without the top padding being chopped off.
  5. 👍 or 👎

@JmillsExpensify
Copy link

$250 approved for @mollfpr

@melvin-bot melvin-bot bot added the Overdue label May 13, 2024
@sakluger
Copy link
Contributor

Thanks!

@melvin-bot melvin-bot bot removed the Overdue label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
No open projects
Development

No branches or pull requests

10 participants