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

[CP Staging] fix: FAB is not responsive after exiting create expense flow #56865

Merged
merged 6 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/libs/Navigation/navigateAfterInteraction/index.ios.ts
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);
});
}
Comment on lines +8 to +12
Copy link
Member

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?


export default navigateAfterInteraction;
5 changes: 5 additions & 0 deletions src/libs/Navigation/navigateAfterInteraction/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function navigateAfterInteraction(callback: () => void) {
callback();
}

export default navigateAfterInteraction;
159 changes: 86 additions & 73 deletions src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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),
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Expand All @@ -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}
/>
Expand Down