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

refactor CreateMenu to have dynamic items #1548

Merged
merged 12 commits into from
Mar 22, 2021

Conversation

Maftalion
Copy link
Contributor

@Maftalion Maftalion commented Feb 23, 2021

Details

  • updated CreateMenu to take a dynamic list of items based on MENU_ITEM_KEYS enum
  • updated ReportActionCompose to open the original attachment modal when AttachmentPicker is selected

Fixed Issues

Fixes https://github.com//issues/1508

Tests

  1. log in and click on the + fab to verify list has new items
  2. enter a convo with more than one person to see SplitBill|AddAttachment options when clicking the attach icon
  3. enter a convo with one person to see RequestMoney |AddAttachment options when clicking the attach icon

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Video Walkthrough

Screen.Recording.2021-02-22.at.10.33.44.PM.mov

Screenshots

Web

Screen Shot 2021-02-22 at 10 22 47 PM

Mobile Web

Screen Shot 2021-02-22 at 10 50 49 PM

Desktop

Screen Shot 2021-02-22 at 10 12 33 PM

iOS

Screen Shot 2021-02-22 at 10 07 21 PM

Android

Screen Shot 2021-02-22 at 10 29 25 PM

@Maftalion Maftalion requested a review from a team as a code owner February 23, 2021 06:53
@github-actions
Copy link
Contributor

github-actions bot commented Feb 23, 2021

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@botify botify requested review from thienlnam and removed request for a team February 23, 2021 06:53
@Maftalion
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

style={styles.chatItemAttachButton}
underlayColor={themeColors.componentBG}
>
<Icon src={Paperclip} />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

left this icon as a Paperclip, might want to update to make it seem more like a menu icon

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah good point, I forgot to mention but we have a new icon for this.

Copy link
Contributor

@thienlnam thienlnam left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Code looks mostly good, just a couple of comments

src/components/CreateMenu.js Outdated Show resolved Hide resolved
src/pages/home/report/ReportActionCompose.js Show resolved Hide resolved
@thienlnam
Copy link
Contributor

Also, could you update your PR to fix the merge conflict and the description to update the fixed issued link, and I think you mean

enter a convo with more one person to see RequestMoney |AddAttachment options when clicking the attach icon

Enter a convo with just one person?

Julesssss
Julesssss previously approved these changes Feb 24, 2021
Copy link
Contributor

@Julesssss Julesssss left a comment

Choose a reason for hiding this comment

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

Looking good 👍

Apart from a few minor comments, I think the main change necessary is an improvement to the hack that @thienlnam pointed out.

@thienlnam
Copy link
Contributor

Tried to test the PR but it doesn't seem like the Add Attachment button is working for me at all even with the timeout

@Maftalion
Copy link
Contributor Author

Tried to test the PR but it doesn't seem like the Add Attachment button is working for me at all even with the timeout

hmm looks the change to conditionally render the component with {this.state.isMenuVisible ? ( causes it to not work. going to investigate further.

@Maftalion
Copy link
Contributor Author

@Julesssss looks like conditionally rendering using this.state.isMenuVisible causes the component to unmount before it can call onModalHide.
I can fix this by adding:

    componentWillUnmount() {
        this.onModalHide();
    }

let me know if this is fine, otherwise I can revert the conditional rendering.

I haven't been able to get the modals to work without using setTimeout, what's strange is onModalHide is supposed to be the solution to opening a modal once another closes so not sure why it's not working.

@Julesssss
Copy link
Contributor

@Maftalion ah, lets revert to the previous solution then.

I'm also not sure why the callback doesn't work without setTimeout, it might be worth sharing the issue in the Contributor chat slack channel to see if anyone else has an idea.

@Julesssss
Copy link
Contributor

Hey @Expensify/design, would you mind sharing the new plus icon asset that will replace the paperclip icon. Shown in the following screenshot:

Chat (4)

@Julesssss
Copy link
Contributor

Julesssss commented Feb 26, 2021

Hmm, the setTimeout issue is a tricky one.

I tried looking for a specific callback that was closing the AttachmentPicker with no luck — the ReportActionCompose Component props aren’t changing (I thought this might be the issue)

I noticed that only iOS has the Attachment closing issue btw. Android, Web & Desktop all work fine, so it might be worth looking for similar iOS bugs/solutions.

I’m a bit confused by the reverse nesting of within and wonder if this is necessary/could be made simpler? This isn't in scope for this PR though

@Maftalion
Copy link
Contributor Author

I’m a bit confused by the reverse nesting of within and wonder if this is necessary/could be made simpler? This isn't in scope for this PR though - yeah, definitely makes it tricky to debug as well

Regarding the plus asset, I noticed we already have it so I can just swap it in. Do you also want the border gone like your screenshot above or is this fine?

Screen Shot 2021-02-27 at 12 25 03 AM

@shawnborton
Copy link
Contributor

@Maftalion your screenshot looks perfect, let's go with that.

@Julesssss
Copy link
Contributor

Hey @Maftalion. just wanted to check in and provide some guidance for moving forward.

As we'll need to resolve the issue without the setTimeout workaround, the next step will be to locate the cause (bug in Expensify.cash OR bug in external library). If this is an internal bug we should aim to fix it as part of the PR, but in the case where this is an external issue we could leave the PR on hold and mark the UpWork complete.

We would then aim to resolve the issue within the offending library and if this was of interest to you we would treat this as a separate issue and provide an additional payment. Once the library issue is fixed, this PR can be taken off hold and merged.

@Maftalion
Copy link
Contributor Author

Hey @Julesssss, I've been unable to get it to work without the setTimeout.

I've tried looking for re-render issues, moving things around and calling the Api directly instead of openPicker but all attempts were unsuccessful.

I then looked into the react-native-image-picker and there seems to be major breaking changes between the current version and the latest so the whole actionsheet would need to be redone in order to test the latest version. But i also tested swapping it out with RN's built in ActionSheetIOS and that led to the same behavior.

Which meant the issue was probably with the modal library react-native-modal. There seems to be a lot of similar issues as this: https://github.com/react-native-modal/react-native-modal/issues?q=is%3Aissue+onmodalhide and a few lead to the same solution of just using setTimeout.

@Julesssss
Copy link
Contributor

Hey @Maftalion, apologies for the delayed response. Thanks for looking into the modal library and potential solutions.

Lets leave this PR on hold while I try to get the react-native-modal library issue created. I'll update this PR once I have an update.

@Julesssss
Copy link
Contributor

Hi @Maftalion. I'm sorry for keeping you waiting for so long!

To move forward, we'll merge this PR with the setTimeout workaround.

Would you mind fixing the conflicts with master to finish up here? I'll make sure to add a bonus to the payout as this is due to my delay.

# Conflicts:
#	src/CONST.js
#	src/components/CreateMenu.js
#	src/components/Icon/Expensicons.js
#	src/pages/home/ReportScreen.js
#	src/pages/home/report/ReportActionCompose.js
#	src/pages/home/report/ReportView.js
#	src/pages/home/sidebar/SidebarScreen.js
@Maftalion
Copy link
Contributor Author

@Julesssss no worries! fixed the merge conflicts

@Julesssss
Copy link
Contributor

Okay, we're almost there.

I'm going to branch from here to prepare a PR locking the feature behind the new internal IOU Beta flag, once this is completed I will merge this issue and quickly follow it up by merging the beta flag PR.

Should be first thing Monday.

@Julesssss Julesssss merged commit fe0ea56 into Expensify:master Mar 22, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Mar 22, 2021
@isagoico
Copy link

Hello! @Julesssss @Maftalion
We were about to do the QA for this PR and came across this other PR #1548. On the latter the options that we need to test for this one are actually expected to be hidden right?
This would block us from being to execute the steps for this PR.

@Julesssss
Copy link
Contributor

Hi @isagoico.

Yeah, good point. Let's skip testing for this one in that case. I'll add the test steps to the PR which re-enables the new options.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants