Skip to content

Commit b241f2a

Browse files
authored
Merge pull request Expensify#72103 from software-mansion-labs/wide-rhp/esc-dismiss
Expense - ESC key closes two RHPs instead of one RHP
2 parents 8d9f96c + 41d1cdd commit b241f2a

6 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {FullScreenContextProvider} from './components/VideoPlayerContexts/FullSc
3838
import {PlaybackContextProvider} from './components/VideoPlayerContexts/PlaybackContext';
3939
import {VideoPopoverMenuContextProvider} from './components/VideoPlayerContexts/VideoPopoverMenuContext';
4040
import {VolumeContextProvider} from './components/VideoPlayerContexts/VolumeContext';
41+
import WideRHPContextProvider from './components/WideRHPContextProvider';
4142
import {KeyboardStateProvider} from './components/withKeyboardState';
4243
import CONFIG from './CONFIG';
4344
import CONST from './CONST';
@@ -125,6 +126,7 @@ function App() {
125126
SidePanelContextProvider,
126127
ExpensifyCardContextProvider,
127128
KYCWallContextProvider,
129+
WideRHPContextProvider,
128130
]}
129131
>
130132
<CustomStatusBarAndBackground />

src/components/ReportActionItem/MoneyRequestView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ function MoneyRequestView({
613613
const shouldShowReport = !!parentReportID || !!actualParentReport;
614614
const reportCopyValue = !canEditReport ? getReportName(actualParentReport) || actualParentReport?.reportName : undefined;
615615

616-
// In this case we want to use this value. The shouldUseNarrowLayout will always be true as this case is handled when we display ReportScreen in RHP.
616+
// In this case we want to use this value. The shouldUseNarrowLayout will always be true as this case is handled when we display ReportScreen in RHP.
617617
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
618618
const {isSmallScreenWidth} = useResponsiveLayout();
619619
const {wideRHPRouteKeys} = useContext(WideRHPContext);

src/libs/Navigation/AppNavigator/AuthScreens.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {SearchContextProvider} from '@components/Search/SearchContext';
1212
import {useSearchRouterContext} from '@components/Search/SearchRouter/SearchRouterContext';
1313
import SearchRouterModal from '@components/Search/SearchRouter/SearchRouterModal';
1414
import SupportalPermissionDeniedModalProvider from '@components/SupportalPermissionDeniedModalProvider';
15-
import WideRHPContextProvider from '@components/WideRHPContextProvider';
15+
import {WideRHPContext} from '@components/WideRHPContextProvider';
1616
import useAutoUpdateTimezone from '@hooks/useAutoUpdateTimezone';
1717
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
1818
import useOnboardingFlowRouter from '@hooks/useOnboardingFlow';
@@ -152,6 +152,7 @@ function AuthScreens() {
152152
const {isOnboardingCompleted, shouldShowRequire2FAPage} = useOnboardingFlowRouter();
153153
const {initialURL, isAuthenticatedAtStartup, setIsAuthenticatedAtStartup} = useContext(InitialURLContext);
154154
const modalCardStyleInterpolator = useModalCardStyleInterpolator();
155+
const {shouldRenderSecondaryOverlay, dismissToWideReport} = useContext(WideRHPContext);
155156

156157
// State to track whether the delegator's authentication is completed before displaying data
157158
const [isDelegatorFromOldDotIsReady, setIsDelegatorFromOldDotIsReady] = useState(false);
@@ -337,6 +338,11 @@ function AuthScreens() {
337338
return;
338339
}
339340

341+
if (shouldRenderSecondaryOverlay) {
342+
dismissToWideReport();
343+
return;
344+
}
345+
340346
Navigation.dismissModal();
341347
},
342348
shortcutConfig.descriptionKey,
@@ -345,7 +351,7 @@ function AuthScreens() {
345351
true,
346352
);
347353
return () => unsubscribeEscapeKey();
348-
}, [modal?.disableDismissOnEscape, modal?.willAlertModalBecomeVisible]);
354+
}, [dismissToWideReport, modal?.disableDismissOnEscape, modal?.willAlertModalBecomeVisible, shouldRenderSecondaryOverlay]);
349355

350356
// Animation is disabled when navigating to the sidebar screen
351357
const getWorkspaceSplitNavigatorOptions = ({route}: {route: RouteProp<AuthScreensParamList>}) => {
@@ -459,7 +465,6 @@ function AuthScreens() {
459465
LockedAccountModalProvider,
460466
DelegateNoAccessModalProvider,
461467
SupportalPermissionDeniedModalProvider,
462-
WideRHPContextProvider,
463468
]}
464469
>
465470
<RootStack.Navigator

src/libs/actions/IOU.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,7 @@ function dismissModalAndOpenReportInInboxTab(reportID?: string) {
941941
// When a report with one expense is opened in the wide RHP and the user adds another expense, RHP should be dismissed and ROUTES.SEARCH_MONEY_REQUEST_REPORT should be displayed.
942942
if (hasMultipleTransactions && reportID) {
943943
Navigation.dismissModal();
944+
// eslint-disable-next-line @typescript-eslint/no-deprecated
944945
InteractionManager.runAfterInteractions(() => {
945946
Navigation.navigate(ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID}));
946947
});

src/pages/home/ReportScreen.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,11 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
831831
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
832832
const {isSmallScreenWidth} = useResponsiveLayout();
833833

834+
// If true reports that are considered MoneyRequest | InvoiceReport will get the new report table view
834835
const shouldDisplayMoneyRequestActionsList = isMoneyRequestOrInvoiceReport && shouldDisplayReportTableView(report, visibleTransactions ?? []);
835836

837+
// WideRHP should be visible only on wide layout when report is opened in RHP and contains only one expense.
838+
// This view is only available for reports of type CONST.REPORT.TYPE.EXPENSE or CONST.REPORT.TYPE.IOU.
836839
const shouldShowWideRHP =
837840
route.name === SCREENS.SEARCH.REPORT_RHP &&
838841
!isSmallScreenWidth &&
@@ -853,8 +856,6 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
853856
return null;
854857
}
855858

856-
// If true reports that are considered MoneyRequest | InvoiceReport will get the new report table view
857-
858859
return (
859860
<ActionListContext.Provider value={actionListValue}>
860861
<ReactionListWrapper>

src/pages/iou/request/step/DiscardChangesConfirmation/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ function DiscardChangesConfirmation({getHasUnsavedChanges, onCancel}: DiscardCha
6969
cancelText={translate('common.cancel')}
7070
onConfirm={() => {
7171
setIsVisible(false);
72+
// eslint-disable-next-line @typescript-eslint/no-deprecated
7273
InteractionManager.runAfterInteractions(() => {
7374
if (blockedNavigationAction.current) {
7475
navigationRef.current?.dispatch(blockedNavigationAction.current);

0 commit comments

Comments
 (0)