-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[CP Staging] fix: FAB is not responsive after exiting create expense flow #56865
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
98010bc
close modal before executing navigation
nkdengineer 0e6879b
Merge branch 'main' into fix/56796
nkdengineer 0f5bcb0
fix lint
nkdengineer e8d09f3
add comment
nkdengineer f345fc1
Update src/libs/Navigation/navigateAfterInteraction/index.ios.ts
nkdengineer 45c347a
remove unchange
nkdengineer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {InteractionManager} from 'react-native'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
|
||
/** | ||
* On iOS, the navigation transition can sometimes break other animations, such as the closing modal. | ||
* In this case we need to wait for the animation to be complete before executing the navigation | ||
*/ | ||
function navigateAfterInteraction(callback: () => void) { | ||
InteractionManager.runAfterInteractions(() => { | ||
Navigation.setNavigationActionToMicrotaskQueue(callback); | ||
}); | ||
} | ||
|
||
export default navigateAfterInteraction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function navigateAfterInteraction(callback: () => void) { | ||
callback(); | ||
} | ||
|
||
export default navigateAfterInteraction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ import {canActionTask as canActionTaskUtils, canModifyTask as canModifyTaskUtils | |
import {setSelfTourViewed} from '@libs/actions/Welcome'; | ||
import getIconForAction from '@libs/getIconForAction'; | ||
import interceptAnonymousUser from '@libs/interceptAnonymousUser'; | ||
import navigateAfterInteraction from '@libs/Navigation/navigateAfterInteraction'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import {hasSeenTourSelector} from '@libs/onboardingSelectors'; | ||
import {areAllGroupPoliciesExpenseChatDisabled, canSendInvoice as canSendInvoicePolicyUtils, shouldShowPolicy} from '@libs/PolicyUtils'; | ||
|
@@ -454,6 +455,80 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT | |
const canModifyTask = canModifyTaskUtils(viewTourTaskReport, currentUserPersonalDetails.accountID); | ||
const canActionTask = canActionTaskUtils(viewTourTaskReport, currentUserPersonalDetails.accountID); | ||
|
||
const menuItems = [ | ||
...expenseMenuItems, | ||
{ | ||
icon: Expensicons.ChatBubble, | ||
text: translate('sidebarScreen.fabNewChat'), | ||
onSelected: () => interceptAnonymousUser(startNewChat), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please retest the original issue that this interaction manager was added for is still fixed? |
||
}, | ||
...(canSendInvoice | ||
? [ | ||
{ | ||
icon: Expensicons.InvoiceGeneric, | ||
text: translate('workspace.invoices.sendInvoice'), | ||
shouldCallAfterModalHide: shouldRedirectToExpensifyClassic, | ||
onSelected: () => | ||
interceptAnonymousUser(() => { | ||
if (shouldRedirectToExpensifyClassic) { | ||
setModalVisible(true); | ||
return; | ||
} | ||
|
||
startMoneyRequest( | ||
CONST.IOU.TYPE.INVOICE, | ||
// When starting to create an invoice from the global FAB, there is not an existing report yet. A random optimistic reportID is generated and used | ||
// for all of the routes in the creation flow. | ||
generateReportID(), | ||
); | ||
}), | ||
}, | ||
] | ||
: []), | ||
...(canUseSpotnanaTravel | ||
? [ | ||
{ | ||
icon: Expensicons.Suitcase, | ||
text: translate('travel.bookTravel'), | ||
onSelected: () => interceptAnonymousUser(() => Navigation.navigate(ROUTES.TRAVEL_MY_TRIPS)), | ||
}, | ||
] | ||
: []), | ||
...(!hasSeenTour | ||
? [ | ||
{ | ||
icon: Expensicons.Binoculars, | ||
iconStyles: styles.popoverIconCircle, | ||
iconFill: theme.icon, | ||
text: translate('tour.takeATwoMinuteTour'), | ||
description: translate('tour.exploreExpensify'), | ||
onSelected: () => { | ||
openExternalLink(navatticURL); | ||
setSelfTourViewed(isAnonymousUser()); | ||
if (viewTourTaskReport && canModifyTask && canActionTask) { | ||
completeTask(viewTourTaskReport); | ||
} | ||
}, | ||
}, | ||
] | ||
: []), | ||
...(!isLoading && shouldShowNewWorkspaceButton | ||
? [ | ||
{ | ||
displayInDefaultIconColor: true, | ||
contentFit: 'contain' as ImageContentFit, | ||
icon: Expensicons.NewWorkspace, | ||
iconWidth: variables.w46, | ||
iconHeight: variables.h40, | ||
text: translate('workspace.new.newWorkspace'), | ||
description: translate('workspace.new.getTheExpensifyCardAndMore'), | ||
onSelected: () => interceptAnonymousUser(() => Navigation.navigate(ROUTES.WORKSPACE_CONFIRMATION.getRoute(Navigation.getActiveRoute()))), | ||
}, | ||
] | ||
: []), | ||
...quickActionMenuItems, | ||
]; | ||
|
||
return ( | ||
<View style={styles.flexGrow1}> | ||
<PopoverMenu | ||
|
@@ -462,79 +537,17 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT | |
anchorPosition={styles.createMenuPositionSidebar(windowHeight)} | ||
onItemSelected={hideCreateMenu} | ||
fromSidebarMediumScreen={!shouldUseNarrowLayout} | ||
menuItems={[ | ||
...expenseMenuItems, | ||
{ | ||
icon: Expensicons.ChatBubble, | ||
text: translate('sidebarScreen.fabNewChat'), | ||
onSelected: () => interceptAnonymousUser(startNewChat), | ||
}, | ||
...(canSendInvoice | ||
? [ | ||
{ | ||
icon: Expensicons.InvoiceGeneric, | ||
text: translate('workspace.invoices.sendInvoice'), | ||
shouldCallAfterModalHide: shouldRedirectToExpensifyClassic, | ||
onSelected: () => | ||
interceptAnonymousUser(() => { | ||
if (shouldRedirectToExpensifyClassic) { | ||
setModalVisible(true); | ||
return; | ||
} | ||
|
||
startMoneyRequest( | ||
CONST.IOU.TYPE.INVOICE, | ||
// When starting to create an invoice from the global FAB, there is not an existing report yet. A random optimistic reportID is generated and used | ||
// for all of the routes in the creation flow. | ||
generateReportID(), | ||
); | ||
}), | ||
}, | ||
] | ||
: []), | ||
...(canUseSpotnanaTravel | ||
? [ | ||
{ | ||
icon: Expensicons.Suitcase, | ||
text: translate('travel.bookTravel'), | ||
onSelected: () => interceptAnonymousUser(() => Navigation.navigate(ROUTES.TRAVEL_MY_TRIPS)), | ||
}, | ||
] | ||
: []), | ||
...(!hasSeenTour | ||
? [ | ||
{ | ||
icon: Expensicons.Binoculars, | ||
iconStyles: styles.popoverIconCircle, | ||
iconFill: theme.icon, | ||
text: translate('tour.takeATwoMinuteTour'), | ||
description: translate('tour.exploreExpensify'), | ||
onSelected: () => { | ||
openExternalLink(navatticURL); | ||
setSelfTourViewed(isAnonymousUser()); | ||
if (viewTourTaskReport && canModifyTask && canActionTask) { | ||
completeTask(viewTourTaskReport); | ||
} | ||
}, | ||
}, | ||
] | ||
: []), | ||
...(!isLoading && shouldShowNewWorkspaceButton | ||
? [ | ||
{ | ||
displayInDefaultIconColor: true, | ||
contentFit: 'contain' as ImageContentFit, | ||
icon: Expensicons.NewWorkspace, | ||
iconWidth: variables.w46, | ||
iconHeight: variables.h40, | ||
text: translate('workspace.new.newWorkspace'), | ||
description: translate('workspace.new.getTheExpensifyCardAndMore'), | ||
onSelected: () => interceptAnonymousUser(() => Navigation.navigate(ROUTES.WORKSPACE_CONFIRMATION.getRoute(Navigation.getActiveRoute()))), | ||
}, | ||
] | ||
: []), | ||
...quickActionMenuItems, | ||
]} | ||
menuItems={menuItems.map((item) => { | ||
return { | ||
...item, | ||
onSelected: () => { | ||
if (!item.onSelected) { | ||
return; | ||
} | ||
navigateAfterInteraction(item.onSelected); | ||
}, | ||
}; | ||
})} | ||
withoutOverlay | ||
anchorRef={fabRef} | ||
/> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will create delay until animation is done. Is it a best solution here?