You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C+ Checklist Needs Completion] [$500] "Failed to load PDF file" message is not rendering in message preview #35808
changed the title [-] "Failed to load PDF file" message is not rendering in message preview[/-][+][$500] "Failed to load PDF file" message is not rendering in message preview[/+]on Feb 5, 2024
Please re-state the problem that we are trying to solve in this issue.
"Failed to load PDF file" message is not rendering in message preview.
What is the root cause of that problem?
Three is a issue with mention file here. It seems there is an issue with the provided file (index.android.js) where the PDF content is still being rendered even when attachmentCarouselPagerContext is null
What changes do you think we should make in order to solve the problem?
To address this issue, you can modify the code to check for the null value of attachmentCarouselPagerContext and display an error message accordingly. Here is an example of how you can update the code:
{attachmentCarouselPagerContext === null ? (
<View style={[themeStyles.flex1, themeStyles.justifyContentCenter]}>
<Text style={props.errorLabelStyles}>{translate('attachmentView.failedToLoadPDF')}</Text>
</View>
) : (
// same as existing code
)}
include components on top of the function
import useLocalize from '@hooks/useLocalize';
import Text from '@components/Text';
Please re-state the problem that we are trying to solve in this issue
When successfully uploading a corrupt PDF file, the message is not being rendered in the message preview.
What is the root cause of that problem?
Note
The issue is happening on botn iOS / Android native platforms.
We don't see anything on native platforms but we see "Failed to load PDF file." on web. The difference between the native / web platforms is that on native we're applying different styles to the child container View that's rendered within the Pressable when an error exists.
Where is the problem exactly ?
If we take a look within the PDFView/index.native.js we can see that the Pressable that wraps the {this.renderPDFView()} has the following styles applied: flex1, flexRow and alignSelfStretch.
While the container View rendered by renderPDFView has the following styles applied when the error is being rendered: alignItemsCenter and flex1.
These styles have a conflict which make the error View invisible due to the following reasons:
flex1 on the container View within the Pressable:
The use of flex1 is intended to make the View expand to fill the available space in the primary axis of its parent (the Pressable). However, because the Pressable has a flexRow style, its primary axis is horizontal. This means that flex1 would only affect the width of the container View. If there's no explicit height specified for the View or the Pressable, and no other child dictates the height, the View does not have enough height to be visible.
alignItemsCenter on the child View within the Pressable:
Being inside a parent with flexRow (the Pressable), the alignItemsCenter applied to the container View doesn't affect its width but rather its vertical alignment. This leads to the container View being centered vertically with no defined height, resulting in a zero-height View that does not display its contents.
flexRow on the parent Pressable:
This style sets the children of the Pressable to be laid out in a horizontal line. Since flex1 on the child is trying to fill space horizontally, it doesn't provide information about how the View should expand vertically (along the cross axis).
Together, these styles result in the container View taking up all available width due to flex1 while it does not have a defined height to make it visible within the layout. The View needs distinct rules to ensure it takes up space along the vertical axis as well since flexRow on the Pressable causes the main axis to be horizontal.
Without an explicit height (or minimum height), the container View will collapse vertically and not display any of its contents, including the error View / Text when the error is present.
Important
All platforms (web / native) DO render the "Failed to load PDF file." from a code POV but we're not seeing it on native due to the conflicting styles.
What changes do you think we should make in order to solve the problem?
In order to make sure, as mentioned in the RCA that the Pressable's children -> the container View takes up space along the vertical axis as well since flexRow is present on the Pressable, we need to conditionally remove the flexRow style from the Pressable based on whether the error failedToLoadPDF is true.
This is the only way to have both the error comment and the error within the attachment modal render correctly, without affecting the Pressable styles when the error is not present, by keeping the flexRow style.
changed the title [-][HOLD for payment 2024-03-07] [$500] "Failed to load PDF file" message is not rendering in message preview[/-][+][C+ Checklist Needs Completion] [$500] "Failed to load PDF file" message is not rendering in message preview[/+]on Mar 9, 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:
[@getusha] The PR that introduced the bug has been identified. Link to the PR: #21714
[@getusha] 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: https://github.com/Expensify/App/pull/21714/files#r1519516670
[@getusha] 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: N/a
[@getusha] Determine if we should create a regression test for this bug. Yes
[@getusha] 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.
Activity
melvin-bot commentedon Feb 5, 2024
Job added to Upwork: https://www.upwork.com/jobs/~0163673ea563ca697f
[-] "Failed to load PDF file" message is not rendering in message preview[/-][+][$500] "Failed to load PDF file" message is not rendering in message preview[/+]melvin-bot commentedon Feb 5, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @getusha (
External)melvin-bot commentedon Feb 5, 2024
Triggered auto assignment to @greg-schroeder (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.ikevin127 commentedon Feb 5, 2024
Can't reproduce - on my side on Android it shows an error if I try to upload a corrupted PDF.
ishpaul777 commentedon Feb 5, 2024
Can you try reproducing with this one Corrupted.PDF.pdf
kaushiktd commentedon Feb 6, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
"Failed to load PDF file" message is not rendering in message preview.
What is the root cause of that problem?
Three is a issue with mention file here. It seems there is an issue with the provided file (index.android.js) where the PDF content is still being rendered even when
attachmentCarouselPagerContextis nullWhat changes do you think we should make in order to solve the problem?
To address this issue, you can modify the code to check for the null value of
attachmentCarouselPagerContextand display an error message accordingly. Here is an example of how you can update the code:include components on top of the function
and mention below const variable on line#20
What alternative solutions did you explore? (Optional)
You can remove the style [this.props.themeStyles.flexRow] from here
Screenshots:
ikevin127 commentedon Feb 6, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue
When successfully uploading a corrupt PDF file, the message is not being rendered in the message preview.
What is the root cause of that problem?
Note
The issue is happening on botn iOS / Android native platforms.
We don't see anything on native platforms but we see "Failed to load PDF file." on web. The difference between the native / web platforms is that on native we're applying different styles to the child container View that's rendered within the Pressable when an error exists.
Where is the problem exactly ?
If we take a look within the PDFView/index.native.js we can see that the Pressable that wraps the
{this.renderPDFView()}has the following styles applied:flex1,flexRowandalignSelfStretch.While the container View rendered by renderPDFView has the following styles applied when the error is being rendered:
alignItemsCenterandflex1.These styles have a conflict which make the error View invisible due to the following reasons:
flex1on the containerViewwithin the Pressable:flex1is intended to make theViewexpand to fill the available space in the primary axis of its parent (thePressable). However, because thePressablehas aflexRowstyle, its primary axis is horizontal. This means thatflex1would only affect the width of the containerView. If there's no explicit height specified for theViewor thePressable, and no other child dictates the height, theViewdoes not have enough height to be visible.alignItemsCenteron the childViewwithin the Pressable:flexRow(the Pressable), thealignItemsCenterapplied to the containerViewdoesn't affect its width but rather its vertical alignment. This leads to the containerViewbeing centered vertically with no defined height, resulting in a zero-heightViewthat does not display its contents.flexRowon the parentPressable:Pressableto be laid out in a horizontal line. Sinceflex1on the child is trying to fill space horizontally, it doesn't provide information about how theViewshould expand vertically (along the cross axis).Together, these styles result in the container
Viewtaking up all available width due toflex1while it does not have a defined height to make it visible within the layout. TheViewneeds distinct rules to ensure it takes up space along the vertical axis as well sinceflexRowon the Pressable causes the main axis to be horizontal.Without an explicit height (or minimum height), the container
Viewwill collapse vertically and not display any of its contents, including the error View / Text when the error is present.Important
All platforms (web / native) DO render the "Failed to load PDF file." from a code POV but we're not seeing it on native due to the conflicting styles.
What changes do you think we should make in order to solve the problem?
App/src/components/PDFView/index.native.js
Line 188 in 06c7dac
In order to make sure, as mentioned in the RCA that the Pressable's children -> the container View takes up space along the vertical axis as well since
flexRowis present on the Pressable, we need to conditionally remove theflexRowstyle from the Pressable based on whether the errorfailedToLoadPDFis true.This is the only way to have both the error comment and the error within the attachment modal render correctly, without affecting the Pressable styles when the error is not present, by keeping the
flexRowstyle.Changed code:
Videos
Android: Native
Screen.Recording.2024-02-19.at.14.58.35.mov
78 remaining items
ikevin127 commentedon Mar 7, 2024
@greg-schroeder Friendly bump for payments 🫡
greg-schroeder commentedon Mar 8, 2024
Sorry about that, I was OOO yesterday, but I'll process this today!
greg-schroeder commentedon Mar 9, 2024
Processing now
greg-schroeder commentedon Mar 9, 2024
All payments complete. @getusha can you complete the checklist so we can close this out? Thanks!
[-][HOLD for payment 2024-03-07] [$500] "Failed to load PDF file" message is not rendering in message preview[/-][+][C+ Checklist Needs Completion] [$500] "Failed to load PDF file" message is not rendering in message preview[/+]getusha commentedon Mar 11, 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:
[@getusha] The PR that introduced the bug has been identified. Link to the PR: #21714
[@getusha] 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: https://github.com/Expensify/App/pull/21714/files#r1519516670
[@getusha] 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: N/a
[@getusha] Determine if we should create a regression test for this bug. Yes
[@getusha] 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.
Regression Test Proposal
Failed to load PDF filerenders correctly.Do we agree 👍 or 👎
greg-schroeder commentedon Mar 13, 2024
Filing regression test and closing!