Repository navigation
Keep edited file attachments laid out as cards - #101717
Conversation
Editing a comment that holds a file attachment now renders a card instead of a link, but the server echo strips the attachment attributes, so the message leaves the attachment-only render path and the card ends up inline in a Text run. Native Text cannot lay out a card there: it collapses, overlaps the line above, or hides the "(edited)" label after it. Every file anchor now gets its own block, in both the text and the attachment render paths, and the attachment path shows the edited label after that block, which covers the offline edit where the optimistic html still carries the attributes. A file name with underscores also reads as markdown emphasis when the edit is parsed, which left the anchor with <em> children and no label to show. The literal label is restored from the draft after the parse, and the renderer reads the name from the anchor's full text so already stored messages keep a name.
6512c3f to
f3b495a
Compare
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
Render tests drive an edited file attachment through ReportActionItem for the text path, the attachment path with its edited label, an emphasis-wrapped label and text on both sides of the file. An action test checks that editReportComment queues the literal label when it would otherwise parse as emphasis.
The server re-serializes an edited comment without the source attribute, so an attachment-only message stopped counting as one after any edit and the LHN row showed the file name instead of "[Attachment]". The attachment ID survives the round trip and now identifies a file anchor as well. A pasted link to an attachment URL carries neither attribute and stays an ordinary message.
…at list The chat row text is the parser's html-to-text of the action html, and the parser only turns an anchor into [Attachment] while it still carries data-expensify-source. The server drops that attribute on edit, so a text-plus-file message showed the file name in the row after a rename. File anchors are now replaced with the attachment token before the parser runs, using the same anchor test as the render path.
Reviewer Checklist
Screenshots/VideosAndroid: HybridApp101717_android_native.movAndroid: mWeb Chrome101717_android_web.moviOS: HybridApp101717_ios_native.moviOS: mWeb Safari101717_ios_web.movMacOS: Chrome / Safari101717_web_chrome.mov |
|
This PR adds a new |
A file queued while offline is read back as a React Native File before it is appended to the request. That File keeps its name and type on the prototype, and the multipart part is built from the object's own properties, so the part went out without a filename and the server stored the attachment as "file". The name and type are now own properties of the file that is appended.
# Conflicts: # src/libs/ReportActionsUtils.ts
|
@brunovjk I think we are good to move here |
|
We have some conflicts, @mukhrr. I’ll review this PR at the end of the day or tomorrow morning at the latest, if it's OK. I have some other PRs to check. Thanks. |
|
no problem. will resolve conflicts later. It's on tests, so i guess it doesn't prevent from reviewing. thanks |
|
This PR adds a new |
|
This PR adds a new |
|
@luacmartins thanks for the 3rd approval 😅 |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 lakchote has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/lakchote in version: 9.5.20-0 🚀
|
|
No help site update needed. This PR fixes a bug so edited comments keep their file attachments, which is what users already expect, and Chat Features and Moderation Tools already describes this behavior correctly. |
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.5.20-5 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
Editing a comment that holds a file attachment broke it three ways: the server returns the edited anchor without its attachment attributes, so the file rendered as a plain link; an edit saved while the upload was still in flight dropped the file; and a renamed file reverted its name or lost its extension on download. The comment's own markup now identifies the attachment, a deferred edit replays once the upload lands, and the new name travels with the queued file.
Fixed Issues
$ #98743
$ #101689
$ #101692
$ #101744
PROPOSAL:
Tests
Precondition: two
.csvfiles, one named with underscores such asmerchant_rules_import_mock.csvand one with a non-English name such asĂn dặm.csv.merchant_rules_import_mock.csvand send. Wait for the upload to finish.(edited)sits next to the text.merchant_rules_import_mock.csvon its own with no text. Wait for the upload to finish, edit the comment, rename the label tomhant_rules_import_mock.csvand save.(edited)under it.Ăn dặm.csvand send. While the file is still uploading, edit the text and save.124.csv, and save. Verify the file keeps that name once the upload finishes..csvon its own, wait for the upload, edit the label to a name without an extension such asedited per diemand save.edited per diem-<timestamp>.csv, then right click the message, choose Download and verify it downloads under the same name instead of opening a new tab.[](URL)with that same URL in both places. Verify the image is displayed and nothing is left over as raw markdown.Offline tests
.csvfile, then edit the label and save.(edited)under it while the edit is pending..csv, edit the text while it is queued and save. Verify the edited text shows and the file is still there.file.QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged theExpensify/designteam so they can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari