Skip to content

Add attachment button link that links to expensify.com report - #399

Merged
AndrewGable merged 16 commits into
masterfrom
joe-new-tab-reports
Sep 9, 2020
Merged

AndrewGable merged 16 commits into
masterfrom
joe-new-tab-reports

Conversation

@Jag96

@Jag96 Jag96 commented Sep 3, 2020 •

Copy link
Copy Markdown
Contributor

This PR adds the workaround mentioned in #87 (comment) so that users using Expensify Chat can have an easier way of uploading photos.

This workaround is temporary and will be replaced with attachment upload functionality described in #87 (comment). The reason we're adding this workaround first is so that we can get everybody moved over to using DMs on chat.expensify.com ASAP

Tests

  1. Go to a report and click the attachment button, confirm you are taken to the report on expensify.com
  2. From the hamburger menu, tap on the links at the bottom for Desktop/iOS/Android. Confirm they open in a browser window on mobile, and that they open in a new tab on web.

Screenshots

Note the placeholder alignment on Android is an existing issue

Large Text No text
image image
image image

@Jag96 Jag96 self-assigned this Sep 3, 2020
@shawnborton

Copy link
Copy Markdown
Contributor

Mind sharing a screenshot of how this looks so far? Let me know how we can help, too. I'm hoping that we can do something similar to what we've been mocking up where the attachment icon is off to the left:
image

@Jag96 Jag96 changed the title [WIP] Add attachment button link that links to expensify.com report Add attachment button link that links to expensify.com report Sep 3, 2020
@Jag96

Jag96 commented Sep 3, 2020

Copy link
Copy Markdown
Contributor Author

Got the CSS working to have the attachment button on the left, this is ready for review

@shawnborton

Copy link
Copy Markdown
Contributor

Actually I wonder if we want to remove the right border given that the input can grow so much? Maybe that will look a little less weird?

@Jag96

Jag96 commented Sep 3, 2020

Copy link
Copy Markdown
Contributor Author

I agree it looks less awkward without the border when there's a lot of text

Web Mobile
image image
image image

Should I kill the border and update the spacing between the attachment icon and the text field as well?

@shawnborton

Copy link
Copy Markdown
Contributor

Actually let me pull your branch down quickly and see how it feels, but I think the spacing might be okay?

@Jag96

Jag96 commented Sep 3, 2020

Copy link
Copy Markdown
Contributor Author

Updated the screenshots w/ the latest design changes 👍

shawnborton
shawnborton previously approved these changes Sep 3, 2020
@Jag96

Jag96 commented Sep 8, 2020

Copy link
Copy Markdown
Contributor Author

bump @marcaaron

@marcaaron marcaaron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just have one comment. Will test this now.

href,
...props
// eslint-disable-next-line react/jsx-props-no-spreading
}) => (<TouchableOpacity onPress={() => window.open(href, '_blank')} {...props} />);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially wanted to pull the "You Aren't Gonna Need It" alarm on this one since we're only using this component once. But then saw why we were specializing here (i.e. the native/web implementations).

Since we really only need the onPress behavior to be cross-platform why not use a utility method to achieve the same thing? This way we can prefer to use the regular TouchableOpacity and pass the href to that method via its parent?

Another alternative would be to use a render prop or HOC, but I think it's overkill for this case.

<TouchableOpacity onPress={() => openLinkInNewTab(props.href)}/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's more likely that we'll get reuse out of a simple function vs. a React component that has a hardcoded event handler.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense to me, I'll update this use a utility lib 👍

@marcaaron
marcaaron self-requested a review September 8, 2020 22:17
@marcaaron

Copy link
Copy Markdown
Contributor

Tests well for me :)

@Jag96
Jag96 requested a review from tgolen as a code owner September 9, 2020 00:39
@Jag96

Jag96 commented Sep 9, 2020

Copy link
Copy Markdown
Contributor Author

Updated this to use a utility lib, @marcaaron lmk if this is more in line with what you were thinking

marcaaron
marcaaron previously approved these changes Sep 9, 2020

@marcaaron marcaaron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep looks perfect!

@marcaaron

Copy link
Copy Markdown
Contributor

Not sure if we want to get to the bottom of this style issue but this is what it looks like on Android otherwise tests well for me and it's NAB so feel free to merge.

Screenshot 1315

* @param {String} href
*/
const openURLInNewTab = (href) => {
window.open(href, '_blank');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we refactor the <Anchor> component to use openURLInNewTab? It has the same idea where we have to use window.open on web and Linking for native.

cc @marcaaron or @tgolen for thoughts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah! Do they differ in any other way besides this method? I think that's a good case for eliminating two separate implementations by creating a shared behavior instead of components that specialize in a behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it out and it works! I'll remove the Anchor component and add some tests to this PR confirm the behavior

Comment thread src/style/StyleSheet.js Outdated
textInputCompose: {
borderWidth: 0,
borderRadius: 0,
outline: 0,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you didn't add this, but can you remove outline? It's throwing errors on native platforms.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be outlineWidth actually, right? I remember looking into this at one point

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's used in one other spot too, let's remove both instances

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually here is an issue where they discuss it: necolas/react-native-web#48

So it looks like it is supported on RNW, but throws on RN 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, looks like outlineWidth: 0 prevents the outline on the textbox and also doesn't throw an error

@Jag96

Jag96 commented Sep 9, 2020

Copy link
Copy Markdown
Contributor Author

Updated to remove the Anchor component and update outline to outlineWidth, ready for another look

@AndrewGable
AndrewGable merged commit 84c0160 into master Sep 9, 2020
@AndrewGable
AndrewGable deleted the joe-new-tab-reports branch September 9, 2020 19:52
@AndrewGable AndrewGable mentioned this pull request Sep 9, 2020
sajal101agrawal pushed a commit to sajal101agrawal/expensify-app that referenced this pull request Sep 16, 2026
Add attachment button link that links to expensify.com report
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.

5 participants