Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ScreenWrapper from '@components/ScreenWrapper';
import Text from '@components/Text';
import TextInput from '@components/TextInput';

import useDynamicBackPath from '@hooks/useDynamicBackPath';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import {usePersonalDetail} from '@hooks/usePersonalDetails';
Expand All @@ -23,6 +24,7 @@ import {updatePolicyMemberDisplayName} from '@userActions/Policy/Member';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import {DYNAMIC_ROUTES} from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import INPUT_IDS from '@src/types/form/DisplayNameForm';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
Expand All @@ -43,6 +45,7 @@ function WorkspaceMemberDisplayNamePage({route}: WorkspaceMemberDisplayNamePageP
const isLoadingMemberPersonalDetails = isLoadingOnyxValue(memberPersonalDetailsResult);
const hasDisplayNameSet = !!memberPersonalDetails?.firstName || !!memberPersonalDetails?.lastName;
const isPolicyMember = !!memberLogin && !!policy?.employeeList?.[memberLogin];
const backPath = useDynamicBackPath(DYNAMIC_ROUTES.PROFILE_DISPLAY_NAME.path);

// Saving sets the name straight away, so without this the page would block itself while it closes.
const [hasSubmitted, setHasSubmitted] = useState(false);
Expand All @@ -56,6 +59,7 @@ function WorkspaceMemberDisplayNamePage({route}: WorkspaceMemberDisplayNamePageP
policyFeature={CONST.POLICY.POLICY_FEATURE.MEMBERS}
policyFeatureAccess={CONST.POLICY.POLICY_FEATURE_ACCESS.WRITE}
shouldBeBlocked={!isLoadingMemberPersonalDetails && !hasSubmitted && (hasDisplayNameSet || !isPolicyMember)}
fullPageNotFoundViewProps={{onBackButtonPress: () => Navigation.goBack(backPath)}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Route the wide-layout link back to the member profile

On wide web layouts, PageNotFoundFallback sets shouldShowBackButton to false (AccessOrNotFoundWrapper.tsx:151), so the header button wired here is hidden and the only available action is the blocking view's link. Because this object does not also provide onLinkPress, FullPageNotFoundView uses its default Navigation.goBackToHome() handler; therefore, after using browser Forward on desktop, clicking “Go back home” still leaves the member profile instead of returning to it. Pass the profile callback as onLinkPress as well.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This issue is specific to Back button which is addressed as expected. The Go back home navigates to home which is expected as per the link text itself. So, I think we can ignore codex review comment here.

>
<ScreenWrapper
includeSafeAreaPaddingBottom
Expand Down
Loading