Skip to content

Commit c225df3

Browse files
Merge pull request #48002 from bernhardoj/fix/47069-screen-behind-rhp-changes-to-profile-when-clicking-address-from-travel-page
Fix screen behind overlay changes to WS profile when open WS address page
2 parents 0e9f918 + 5ddc50d commit c225df3

File tree

7 files changed

+15
-10
lines changed

7 files changed

+15
-10
lines changed

src/ROUTES.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ const ROUTES = {
547547
},
548548
WORKSPACE_PROFILE_ADDRESS: {
549549
route: 'settings/workspaces/:policyID/profile/address',
550-
getRoute: (policyID: string) => `settings/workspaces/${policyID}/profile/address` as const,
550+
getRoute: (policyID: string, backTo?: string) => getUrlWithBackToParam(`settings/workspaces/${policyID}/profile/address` as const, backTo),
551551
},
552552
WORKSPACE_ACCOUNTING: {
553553
route: 'settings/workspaces/:policyID/accounting',

src/components/CountrySelector.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function CountrySelector({errorText = '', value: countryCode, onInputChange = ()
7575
description={translate('common.country')}
7676
errorText={errorText}
7777
onPress={() => {
78-
const activeRoute = Navigation.getActiveRouteWithoutParams();
78+
const activeRoute = Navigation.getActiveRoute();
7979
didOpenContrySelector.current = true;
8080
Navigation.navigate(ROUTES.SETTINGS_ADDRESS_COUNTRY.getRoute(countryCode ?? '', activeRoute));
8181
}}

src/libs/Navigation/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ type SettingsNavigatorParamList = {
184184
[SCREENS.WORKSPACE.ADDRESS]: {
185185
policyID: string;
186186
country?: Country | '';
187+
backTo?: Routes;
187188
};
188189
[SCREENS.WORKSPACE.NAME]: undefined;
189190
[SCREENS.WORKSPACE.DESCRIPTION]: undefined;

src/pages/AddressPage.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import ScreenWrapper from '@components/ScreenWrapper';
77
import useLocalize from '@hooks/useLocalize';
88
import useThemeStyles from '@hooks/useThemeStyles';
99
import Navigation from '@libs/Navigation/Navigation';
10+
import type {BackToParams} from '@libs/Navigation/types';
1011
import type {FormOnyxValues} from '@src/components/Form/types';
1112
import type {Country} from '@src/CONST';
1213
import ONYXKEYS from '@src/ONYXKEYS';
@@ -22,9 +23,9 @@ type AddressPageProps = {
2223
updateAddress: (values: FormOnyxValues<typeof ONYXKEYS.FORMS.HOME_ADDRESS_FORM>) => void;
2324
/** Title of address page */
2425
title: string;
25-
};
26+
} & BackToParams;
2627

27-
function AddressPage({title, address, updateAddress, isLoadingApp = true}: AddressPageProps) {
28+
function AddressPage({title, address, updateAddress, isLoadingApp = true, backTo}: AddressPageProps) {
2829
const styles = useThemeStyles();
2930
const {translate} = useLocalize();
3031

@@ -83,7 +84,7 @@ function AddressPage({title, address, updateAddress, isLoadingApp = true}: Addre
8384
<HeaderWithBackButton
8485
title={title}
8586
shouldShowBackButton
86-
onBackButtonPress={() => Navigation.goBack()}
87+
onBackButtonPress={() => Navigation.goBack(backTo)}
8788
/>
8889
{isLoadingApp ? (
8990
<FullscreenLoadingIndicator style={[styles.flex1, styles.pRelative]} />

src/pages/Travel/ManageTrips.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function ManageTrips() {
6161
ctaAccessibilityLabel={translate('travel.bookTravel')}
6262
onCtaPress={() => {
6363
if (!hasPolicyAddress) {
64-
Navigation.navigate(ROUTES.WORKSPACE_PROFILE_ADDRESS.getRoute(activePolicyID ?? '-1'));
64+
Navigation.navigate(ROUTES.WORKSPACE_PROFILE_ADDRESS.getRoute(activePolicyID ?? '-1', Navigation.getActiveRoute()));
6565
return;
6666
}
6767
if (!hasAcceptedTravelTerms) {

src/pages/settings/Profile/PersonalDetails/CountrySelectionPage.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
1010
import type {CountryData} from '@libs/searchCountryOptions';
1111
import searchCountryOptions from '@libs/searchCountryOptions';
1212
import StringUtils from '@libs/StringUtils';
13+
import {appendParam} from '@libs/Url';
1314
import CONST from '@src/CONST';
1415
import type {TranslationPaths} from '@src/languages/types';
1516
import type {Route} from '@src/ROUTES';
@@ -49,10 +50,10 @@ function CountrySelectionPage({route, navigation}: CountrySelectionPageProps) {
4950
Navigation.goBack();
5051
} else if (!!backTo && navigation.getState().routes.length === 1) {
5152
// If "backTo" is not empty and there is only one route, go back to the specific route defined in "backTo" with a country parameter
52-
Navigation.goBack(`${route.params.backTo}?country=${option.value}` as Route);
53+
Navigation.goBack(appendParam(backTo, 'country', option.value));
5354
} else {
5455
// Otherwise, navigate to the specific route defined in "backTo" with a country parameter
55-
Navigation.navigate(`${route.params.backTo}?country=${option.value}` as Route);
56+
Navigation.navigate(appendParam(backTo, 'country', option.value));
5657
}
5758
},
5859
[route, navigation],

src/pages/workspace/WorkspaceProfileAddressPage.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ type WorkspaceProfileAddressPagePolicyProps = WithPolicyProps;
1616

1717
type WorkspaceProfileAddressPageProps = StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.ADDRESS> & WorkspaceProfileAddressPagePolicyProps;
1818

19-
function WorkspaceProfileAddressPage({policy}: WorkspaceProfileAddressPageProps) {
19+
function WorkspaceProfileAddressPage({policy, route}: WorkspaceProfileAddressPageProps) {
2020
const {translate} = useLocalize();
21+
const backTo = route.params.backTo;
2122
const address: Address = useMemo(() => {
2223
const tempAddress = policy?.address;
2324
const [street1, street2] = (tempAddress?.addressStreet ?? '').split('\n');
@@ -43,11 +44,12 @@ function WorkspaceProfileAddressPage({policy}: WorkspaceProfileAddressPageProps)
4344
zipCode: values?.zipPostCode?.trim().toUpperCase() ?? '',
4445
country: values.country,
4546
});
46-
Navigation.goBack();
47+
Navigation.goBack(backTo);
4748
};
4849

4950
return (
5051
<AddressPage
52+
backTo={backTo}
5153
address={address}
5254
isLoadingApp={false}
5355
updateAddress={updatePolicyAddress}

0 commit comments

Comments
 (0)