App icon indicating copy to clipboard operation
App copied to clipboard

[PAID] UX issues with Attachment View in Chat

Open akshayasalvi opened this issue 5 years ago • 26 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. Go to chat
  2. Click Add Attachment and select a word docx document.
  3. Upload the document
  4. Now see the preview and try downloading

Expected Result:

  • It should've given a better UX for showing the attachment instead of link
  • Download shouldn't take you to a new tab and filename should be reader-friendly.

Actual Result:

  • UX looks similar to a link than an attachment image

  • Downloading the file opens a new tab and downloads the file with a long random string image

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platform:

Where is this issue occurring?

  • Web
  • iOS
  • Android
  • Desktop App
  • Mobile Web

Version Number: Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos: Any additional supporting documentation Expensify/Expensify Issue URL:

View all open jobs on Upwork

akshayasalvi avatar Aug 12 '21 07:08 akshayasalvi

Triggered auto assignment to @flaviadefaria (AutoAssignerTriage), see https://stackoverflow.com/c/expensify/questions/4749 for more details.

MelvinBot avatar Aug 12 '21 07:08 MelvinBot

Proposed Solution

We can create a custom view for Attachment view in the chatlist. It'll have the filename as well as the download button. A sample UI would look similar to this.

file-download-design

We'll have to update ReportActionItemFragment, case 'COMMENT': section.

	if(fragment.text === '[Attachment]') {
		const fileName = extractFileNameFromLink(fragment.html);
		return (
			<AttachmentView fileName={fileName} rightElement={
				<Pressable onPress={() => fileDownload(fragment.html, fileName) }>
					<Icon src={download} />
				</Pressable>

			} />
		);

	} else if(fragment.html !== fragment.text) {
		// existing code...
	}

Modify the AttachmentView


	<View
            style={styles.defaultAttachmentView}
        >
            <View style={styles.mr2}>
                <Icon src={Paperclip} />
            </View>
            <Text style={[styles.textStrong]}>{props.file && props.file.name}</Text>
            {
            	props.rightElement && ({props.rightElement})
            }
        </View>

Add a param in fileDownload.js,

	export default function fileDownload(url, downloadFileName) {

		// existing code

		const attachmentName = downloadFileName ?? getAttachmentName(url);
		link.setAttribute(
            'download',
            attachmentName
        )

akshayasalvi avatar Aug 12 '21 07:08 akshayasalvi

Triggered auto assignment to @robertjchen (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

MelvinBot avatar Aug 13 '21 14:08 MelvinBot

Triggered auto assignment to @mallenexpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

MelvinBot avatar Aug 13 '21 20:08 MelvinBot

Thank's for bringing up the issue @akshayasalvi , I do agree that the text that looks like a hyperlink looks like a link. @Expensify/design can y'all take a look and provide feedback on the proposed update from image to image

mallenexpensify avatar Aug 16 '21 21:08 mallenexpensify

Yeah, I think that looks great!

michelle-thompson avatar Aug 16 '21 21:08 michelle-thompson

Triggered auto assignment to @thienlnam (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

MelvinBot avatar Aug 16 '21 22:08 MelvinBot

Job created in Upwork - https://www.upwork.com/jobs/~012a60478f2a5dfa9a @thienlnam can you please review @akshayasalvi 's proposal above?

mallenexpensify avatar Aug 16 '21 22:08 mallenexpensify

@akshayasalvi Thanks for the clear proposal! After taking a look here are a couple things I've noticed

We'll have to update ReportActionItemFragment, case 'COMMENT': section.

We should be handling this in BaseRenderHTML, the 'attachment' in this case is just an anchor tag. Can you outline a solution that would exist here? https://github.com/Expensify/App/blob/88593d4f00f38bf97c70da9dfb97b80bb9b381a4/src/components/RenderHTML/BaseRenderHTML.js#L67-L90

Modify the AttachmentView

Instead of adding a prop for rightElement, we should instead just include the file download icon and instead choose to conditionally render it with shouldShowDownloadIcon or something similar

Add a param in fileDownload.js,

These changes look fine for web but how will you handle this for native devices?

thienlnam avatar Aug 17 '21 17:08 thienlnam

@thienlnam I couldn't find BaseRenderHTML in the main branch. Is it a part of the working branch? I did find https://github.com/Expensify/App/blob/main/src/components/RenderHTML.js in the main branch.

Then the same changes in terms of the UI can be pulled into: https://github.com/Expensify/App/blob/88593d4f00f38bf97c70da9dfb97b80bb9b381a4/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly/index.js component.

These changes look fine for web but how will you handle this for native devices?

I was relying on the existing functionality of download attachments. But it seems the current App download doesn't work (atleast in the iPhone). I tried downloading an image as well as a pdf. We can use react-native-fs to add a download logic for all attachments. But do you want to keep this in the same task? This was more of the UX of the attachment view.

akshayasalvi avatar Aug 17 '21 21:08 akshayasalvi

@akshayasalvi Ah yeah my bad looks like the HTML render has been moved, I meant in this file https://github.com/Expensify/App/blob/bd863d61b3e0161dcce0e0085f02a10923bea876/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js

I was relying on the existing functionality of download attachments. But it seems the current App download doesn't work (atleast in the iPhone). I tried downloading an image as well as a pdf. We can use react-native-fs to add a download logic for all attachments. But do you want to keep this in the same task? This was more of the UX of the attachment view.

We don't need to worry about adding native download logic in this issue, but just make sure the UX changes also reflect on native devices

🟢 on the proposal

thienlnam avatar Aug 18 '21 01:08 thienlnam

@mallenexpensify could you please hire @akshayasalvi for this job?

thienlnam avatar Aug 18 '21 01:08 thienlnam

@thienlnam Is there a way to get the filename in the BaseAnchorForCommentsOnly. I've checked that it just sends HTML to the renderHTML. In Text the children, it loads an element and I don't have a way to get just the filename.

<Text
          ref={el => linkRef = el}
          style={StyleSheet.flatten(style)}
          accessibilityRole="link"
          href={href}
          hrefAttrs={{rel, target}}
         // eslint-disable-next-line react/jsx-props-no-spreading
          {...props}  
      >
      {children}
</Text>

If there isn't a direct way to get the filename then I'll figure out a way to pass it to props or something. This is how it looks right now with the UX changes.

image

akshayasalvi avatar Aug 18 '21 16:08 akshayasalvi

You'd probably have to pass it down via props here, likely by extracting it from htmlAttribs. If we need to add an attribute to the html element to include the name let me know

thienlnam avatar Aug 18 '21 16:08 thienlnam

Honestly, passing a name would be better. Not only for the documents but also for image. I can then just pick that and display it with htmlAttribs

akshayasalvi avatar Aug 18 '21 17:08 akshayasalvi

Honestly, passing a name would be better. Not only for the documents but also for image. I can then just pick that and display it with htmlAttribs

Can you clarify this? Do you need a name to be passed to the html element which would show up in htmlAttribs?

thienlnam avatar Aug 18 '21 17:08 thienlnam

@thienlnam I've managed to find the filename from the TextNode. Please check the draft PR. If that doesn't work well then I would required the name to be passed in the HTML such as data-filename, which I can use to pass as prop.

akshayasalvi avatar Aug 18 '21 17:08 akshayasalvi

Sweet, @akshayasalvi Could you please apply for the upwork job here so we can get you hired before continuing work on the PR?

thienlnam avatar Aug 18 '21 17:08 thienlnam

I've applied on Upwork

akshayasalvi avatar Aug 18 '21 18:08 akshayasalvi

Hired @akshayasalvi in Upwork. The bonus for reporting the issue will be added at the end upon payment for the job.

mallenexpensify avatar Aug 18 '21 20:08 mallenexpensify