Skip to content
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7586,6 +7586,7 @@ const CONST = {
// that should be removed from the copied contents in the getHTMLOfSelection() method
SELECTION_SCRAPER_HIDDEN_ELEMENT: 'selection-scrapper-hidden-element',
INNER_BOX_SHADOW_ELEMENT: 'inner-box-shadow-element',
TAB_BAR_LABEL_BOLD_PLACEHOLDER: 'tab-bar-label-bold-placeholder',
COPYABLE_TEXT_ELEMENT: 'copyable-text',
COPYABLE_ROW_ELEMENT: 'copyable-row',
COPYABLE_ROW_CONTINUATION_ELEMENT: 'copyable-row-continuation',
Expand Down
6 changes: 6 additions & 0 deletions src/components/Navigation/FlatNavigationBar/FlatNavItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import variables from '@styles/variables';

import CONST from '@src/CONST';
import type {Route} from '@src/ROUTES';
import type IconAsset from '@src/types/utils/IconAsset';
import type {SentryLabel} from '@src/types/utils/SentryLabel';

Expand Down Expand Up @@ -50,6 +51,9 @@ type FlatNavItemProps = {

onPress: () => void;

/** Route of the destination, so the row can be opened in a new browser tab */
linkRoute?: Route;

/** Called when the pointer moves onto the row */
onHoverIn?: () => void;

Expand All @@ -70,6 +74,7 @@ function FlatNavItem({
accessibilityLabel,
sentryLabel,
onPress,
linkRoute,
onHoverIn,
onHoverOut,
}: FlatNavItemProps) {
Expand All @@ -90,6 +95,7 @@ function FlatNavItem({
return (
<PressableWithFeedback
onPress={onPress}
linkRoute={linkRoute}
role={CONST.ROLE.TAB}
accessibilityLabel={accessibilityLabel ?? label}
accessibilityState={{selected: isSelected}}
Expand Down
2 changes: 2 additions & 0 deletions src/components/Navigation/FlatNavigationBar/FlatNavLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import useTheme from '@hooks/useTheme';
import variables from '@styles/variables';

import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';

import React from 'react';

Expand All @@ -30,6 +31,7 @@ function FlatNavLogo({onPress, isCollapsed = false}: FlatNavLogoProps) {
accessibilityLabel={translate('common.home')}
testID="ExpensifyLogoButton"
onPress={onPress}
linkRoute={ROUTES.HOME}
Comment thread
Krishna2323 marked this conversation as resolved.
Resolved
sentryLabel={CONST.SENTRY_LABEL.NAVIGATION_TAB_BAR.EXPENSIFY_LOGO}
aria-hidden={isCollapsed}
tabIndex={isCollapsed ? -1 : 0}
Expand Down
12 changes: 12 additions & 0 deletions src/components/Navigation/FlatNavigationBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import AccountNavigationAvatar from '@components/Avatar/AccountNavigationAvatar'
import EnvironmentBadge from '@components/EnvironmentBadge';
import Hoverable from '@components/Hoverable';
import DebugTabView from '@components/Navigation/DebugTabView';
import {DEFAULT_INSIGHTS_TAB_ROUTE} from '@components/Navigation/NavigationTabBar/getInsightsTabRoute';
import getTabAccessibilityLabel from '@components/Navigation/NavigationTabBar/getTabAccessibilityLabel';
import NAVIGATION_TABS from '@components/Navigation/NavigationTabBar/NAVIGATION_TABS';
import useAccountTabNavigation from '@components/Navigation/NavigationTabBar/useAccountTabNavigation';
import useHomeTabNavigation from '@components/Navigation/NavigationTabBar/useHomeTabNavigation';
import useInsightsTabNavigation from '@components/Navigation/NavigationTabBar/useInsightsTabNavigation';
import useSearchTabNavigation from '@components/Navigation/NavigationTabBar/useSearchTabNavigation';
import useSignedInLinkRoute from '@components/Navigation/NavigationTabBar/useSignedInLinkRoute';
import useStoredSearchTabRoute from '@components/Navigation/NavigationTabBar/useStoredSearchTabRoute';
import useWideInboxNavigation from '@components/Navigation/NavigationTabBar/useWideInboxNavigation';
import {
COLLAPSE_SURFACE,
Expand Down Expand Up @@ -38,6 +41,7 @@ import SupportalSwitcherButton from '@pages/inbox/sidebar/SupportalSwitcherButto

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';

import type {ComponentRef} from 'react';
import type {NativeSyntheticEvent, TargetedEvent} from 'react-native';
Expand Down Expand Up @@ -76,6 +80,8 @@ function FlatNavigationBar({selectedTab}: FlatNavigationBarProps) {

const navigateToInbox = useWideInboxNavigation(selectedTab === NAVIGATION_TABS.INBOX);
const navigateToSearch = useSearchTabNavigation(selectedTab === NAVIGATION_TABS.SEARCH);
const getSignedInLinkRoute = useSignedInLinkRoute();
const storedSearchTabRoute = useStoredSearchTabRoute();
const navigateToInsights = useInsightsTabNavigation(selectedTab === NAVIGATION_TABS.INSIGHTS);
const navigateToWorkspaces = useRestoreWorkspacesTabOnNavigate();

Expand Down Expand Up @@ -209,6 +215,7 @@ function FlatNavigationBar({selectedTab}: FlatNavigationBarProps) {
isSelected={isHomeSelected}
sentryLabel={CONST.SENTRY_LABEL.NAVIGATION_TAB_BAR.HOME}
onPress={navigateToHome}
linkRoute={ROUTES.HOME}
/>
<FlatNavItem
isCollapsed={isVisuallyCollapsed}
Expand All @@ -219,6 +226,7 @@ function FlatNavigationBar({selectedTab}: FlatNavigationBarProps) {
accessibilityLabel={getTabAccessibilityLabel(translate('common.inbox'), !!inboxStatus, translate)}
sentryLabel={CONST.SENTRY_LABEL.NAVIGATION_TAB_BAR.INBOX}
onPress={navigateToInbox}
linkRoute={ROUTES.INBOX}
/>
<FlatNavDivider />
<FlatNavItem
Expand All @@ -228,6 +236,7 @@ function FlatNavigationBar({selectedTab}: FlatNavigationBarProps) {
isSelected={selectedTab === NAVIGATION_TABS.SEARCH}
sentryLabel={CONST.SENTRY_LABEL.NAVIGATION_TAB_BAR.REPORTS}
onPress={navigateToSearch}
linkRoute={getSignedInLinkRoute(storedSearchTabRoute)}
onHoverIn={() => setIsSearchTabHovered(true)}
onHoverOut={() => setIsSearchTabHovered(false)}
/>
Expand All @@ -238,6 +247,7 @@ function FlatNavigationBar({selectedTab}: FlatNavigationBarProps) {
isSelected={selectedTab === NAVIGATION_TABS.INSIGHTS}
sentryLabel={CONST.SENTRY_LABEL.NAVIGATION_TAB_BAR.INSIGHTS}
onPress={navigateToInsights}
linkRoute={getSignedInLinkRoute(DEFAULT_INSIGHTS_TAB_ROUTE)}
/>
<FlatNavDivider />
<FlatNavItem
Expand All @@ -249,6 +259,7 @@ function FlatNavigationBar({selectedTab}: FlatNavigationBarProps) {
accessibilityLabel={getTabAccessibilityLabel(translate('common.workspacesTabTitle'), !!workspacesStatus, translate)}
sentryLabel={CONST.SENTRY_LABEL.NAVIGATION_TAB_BAR.WORKSPACES}
onPress={navigateToWorkspaces}
linkRoute={getSignedInLinkRoute(ROUTES.WORKSPACES_LIST.route)}
/>
</ScrollView>
</View>
Expand All @@ -275,6 +286,7 @@ function FlatNavigationBar({selectedTab}: FlatNavigationBarProps) {
accessibilityLabel={getTabAccessibilityLabel(`${accountLabel}, ${translate('sidebarScreen.buttonMySettings')}`, !!accountStatus, translate)}
sentryLabel={CONST.SENTRY_LABEL.NAVIGATION_TAB_BAR.ACCOUNT}
onPress={navigateToAccount}
linkRoute={getSignedInLinkRoute(ROUTES.SETTINGS)}
/>
</View>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';

import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';

import type {ValueOf} from 'type-fest';

Expand Down Expand Up @@ -40,6 +41,7 @@ function WideInboxTabButton({selectedTab, statusIndicatorColor, accessibilityLab
return (
<PressableWithFeedback
onPress={navigateToChats}
linkRoute={ROUTES.INBOX}
role={CONST.ROLE.TAB}
accessibilityLabel={accessibilityLabel}
accessibilityState={{selected: selectedTab === NAVIGATION_TABS.INBOX}}
Expand Down Expand Up @@ -87,6 +89,7 @@ function InboxTabButton({selectedTab, isWideLayout}: InboxTabButtonProps) {
return (
<PressableWithFeedback
onPress={navigateToChats}
linkRoute={ROUTES.INBOX}
role={CONST.ROLE.TAB}
accessibilityLabel={accessibilityLabel}
accessibilityState={{selected: selectedTab === NAVIGATION_TABS.INBOX}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import type {ValueOf} from 'type-fest';

import React from 'react';

import {DEFAULT_INSIGHTS_TAB_ROUTE} from './getInsightsTabRoute';
import NAVIGATION_TABS from './NAVIGATION_TABS';
import TabBarItem from './TabBarItem';
import useInsightsTabNavigation from './useInsightsTabNavigation';
import useSignedInLinkRoute from './useSignedInLinkRoute';

type InsightsTabButtonProps = {
selectedTab: ValueOf<typeof NAVIGATION_TABS>;
Expand All @@ -25,11 +27,14 @@ function InsightsTabButton({selectedTab, isWideLayout}: InsightsTabButtonProps)
const expensifyIcons = useMemoizedLazyExpensifyIcons(['PieChart']);
const isSelected = selectedTab === NAVIGATION_TABS.INSIGHTS;
const navigateToInsights = useInsightsTabNavigation(isSelected);
const getSignedInLinkRoute = useSignedInLinkRoute();
const insightsLinkRoute = getSignedInLinkRoute(DEFAULT_INSIGHTS_TAB_ROUTE);

if (isWideLayout) {
return (
<PressableWithFeedback
onPress={navigateToInsights}
linkRoute={insightsLinkRoute}
role={CONST.ROLE.TAB}
accessibilityLabel={translate('common.insights')}
accessibilityState={{selected: isSelected}}
Expand All @@ -51,6 +56,7 @@ function InsightsTabButton({selectedTab, isWideLayout}: InsightsTabButtonProps)
return (
<PressableWithFeedback
onPress={navigateToInsights}
linkRoute={insightsLinkRoute}
role={CONST.ROLE.TAB}
accessibilityLabel={translate('common.insights')}
accessibilityState={{selected: isSelected}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import React, {useEffect} from 'react';
import NAVIGATION_TABS from './NAVIGATION_TABS';
import TabBarItem from './TabBarItem';
import useSearchTabNavigation from './useSearchTabNavigation';
import useSignedInLinkRoute from './useSignedInLinkRoute';
import useStoredSearchTabRoute from './useStoredSearchTabRoute';

type SearchTabButtonProps = {
selectedTab: ValueOf<typeof NAVIGATION_TABS>;
Expand All @@ -27,6 +29,8 @@ function SearchTabButton({selectedTab, isWideLayout}: SearchTabButtonProps) {
const expensifyIcons = useMemoizedLazyExpensifyIcons(['ReceiptMultiple']);
const searchAccessibilityState = {selected: selectedTab === NAVIGATION_TABS.SEARCH};
const navigateToSearch = useSearchTabNavigation(selectedTab === NAVIGATION_TABS.SEARCH);
const getSignedInLinkRoute = useSignedInLinkRoute();
const searchTabRoute = getSignedInLinkRoute(useStoredSearchTabRoute());

// The wide button gets no hover out when it goes away while hovered, on a switch to the narrow layout or an unmount.
useEffect(() => () => setIsSearchTabHovered(false), [isWideLayout]);
Expand All @@ -35,6 +39,7 @@ function SearchTabButton({selectedTab, isWideLayout}: SearchTabButtonProps) {
return (
<PressableWithFeedback
onPress={navigateToSearch}
linkRoute={searchTabRoute}
role={CONST.ROLE.TAB}
accessibilityLabel={translate('common.spend')}
accessibilityState={searchAccessibilityState}
Expand All @@ -58,6 +63,7 @@ function SearchTabButton({selectedTab, isWideLayout}: SearchTabButtonProps) {
return (
<PressableWithFeedback
onPress={navigateToSearch}
linkRoute={searchTabRoute}
role={CONST.ROLE.TAB}
accessibilityLabel={translate('common.spend')}
accessibilityState={searchAccessibilityState}
Expand Down
10 changes: 5 additions & 5 deletions src/components/Navigation/NavigationTabBar/TabBarLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import type {StyleProp, ViewStyle} from 'react-native';
import React from 'react';
import {View} from 'react-native';

import TabBarLabelBoldPlaceholder from './TabBarLabelBoldPlaceholder';

type TabBarLabelProps = {
label: string;
isSelected: boolean;
Expand All @@ -27,13 +29,11 @@ function TabBarLabel({label, isSelected, numberOfLines, style}: TabBarLabelProps
>
{label}
</Text>
<Text
aria-hidden
<TabBarLabelBoldPlaceholder
label={label}
numberOfLines={numberOfLines}
style={[textStyle, styles.textBold, styles.navigationTabBarLabelBoldPlaceholder]}
>
{label}
</Text>
/>
</View>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Text from '@components/Text';

import React from 'react';

import type TabBarLabelBoldPlaceholderProps from './types';

function TabBarLabelBoldPlaceholder({label, numberOfLines, style}: TabBarLabelBoldPlaceholderProps) {
return (
<Text
aria-hidden
numberOfLines={numberOfLines}
style={style}
>
{label}
</Text>
);
}

export default TabBarLabelBoldPlaceholder;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Text from '@components/Text';

import CONST from '@src/CONST';

import React from 'react';

import type TabBarLabelBoldPlaceholderProps from './types';

/** The label is drawn by a CSS pseudo-element, so it stays out of the text a browser takes when the tab link is dragged or copied. */
function TabBarLabelBoldPlaceholder({label, numberOfLines, style}: TabBarLabelBoldPlaceholderProps) {
return (
<Text
aria-hidden
numberOfLines={numberOfLines}
style={style}
dataSet={{[CONST.TAB_BAR_LABEL_BOLD_PLACEHOLDER]: label}}
>
{null}
</Text>
);
}

export default TabBarLabelBoldPlaceholder;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type {StyleProp, TextStyle} from 'react-native';

type TabBarLabelBoldPlaceholderProps = {
/** Tab label whose bold width is reserved. On web it goes in a data attribute instead of the text, so it stays out of the link text */
label: string;

/** Number of lines the visible label is limited to */
numberOfLines: number;

/** Style of the visible label in bold, so the placeholder takes the same width */
style: StyleProp<TextStyle>;
};
Comment thread
Krishna2323 marked this conversation as resolved.
Resolved

export default TabBarLabelBoldPlaceholderProps;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import useWorkspacesTabIndicatorStatus from '@hooks/useWorkspacesTabIndicatorStatus';

import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';

import type {ValueOf} from 'type-fest';

Expand All @@ -15,6 +16,7 @@ import React from 'react';
import getTabAccessibilityLabel from './getTabAccessibilityLabel';
import NAVIGATION_TABS from './NAVIGATION_TABS';
import TabBarItem from './TabBarItem';
import useSignedInLinkRoute from './useSignedInLinkRoute';

type WorkspacesTabButtonProps = {
selectedTab: ValueOf<typeof NAVIGATION_TABS>;
Expand All @@ -28,6 +30,8 @@ function WorkspacesTabButton({selectedTab, isWideLayout}: WorkspacesTabButtonPro
const {indicatorColor: workspacesTabIndicatorColor, status: workspacesTabIndicatorStatus} = useWorkspacesTabIndicatorStatus();

const navigateToWorkspaces = useRestoreWorkspacesTabOnNavigate();
const getSignedInLinkRoute = useSignedInLinkRoute();
const workspacesLinkRoute = getSignedInLinkRoute(ROUTES.WORKSPACES_LIST.route);

const workspacesAccessibilityState = {selected: selectedTab === NAVIGATION_TABS.WORKSPACES};
const workspacesStatusIndicatorColor = workspacesTabIndicatorStatus ? workspacesTabIndicatorColor : undefined;
Expand All @@ -36,6 +40,7 @@ function WorkspacesTabButton({selectedTab, isWideLayout}: WorkspacesTabButtonPro
return (
<PressableWithFeedback
onPress={navigateToWorkspaces}
linkRoute={workspacesLinkRoute}
role={CONST.ROLE.TAB}
accessibilityLabel={getTabAccessibilityLabel(translate('common.workspacesTabTitle'), !!workspacesTabIndicatorStatus, translate)}
accessibilityState={workspacesAccessibilityState}
Expand All @@ -59,6 +64,7 @@ function WorkspacesTabButton({selectedTab, isWideLayout}: WorkspacesTabButtonPro
return (
<PressableWithFeedback
onPress={navigateToWorkspaces}
linkRoute={workspacesLinkRoute}
role={CONST.ROLE.TAB}
accessibilityLabel={getTabAccessibilityLabel(translate('common.workspacesTabTitle'), !!workspacesTabIndicatorStatus, translate)}
accessibilityState={workspacesAccessibilityState}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import type {InsightsDashboardID} from '@src/types/onyx';

import type {NavigationState} from '@react-navigation/native';

/** The Insights route opened when there is no last dashboard to return to, such as in a new browser tab */
const DEFAULT_INSIGHTS_TAB_ROUTE = ROUTES.INSIGHTS.getRoute(CONST.INSIGHTS.DASHBOARD.SPEND);

/** Returns the route of the dashboard the Insights tab last showed, or Spend when there is none or it is no longer accessible. */
function getInsightsTabRoute(rootState: NavigationState | undefined, accessibleDashboards: InsightsDashboardID[]) {
const insightsParams = getTabNavigatorRoute(rootState)?.state?.routes.find((route) => route.name === SCREENS.INSIGHTS)?.params;
Expand All @@ -16,7 +19,8 @@ function getInsightsTabRoute(rootState: NavigationState | undefined, accessibleD
return ROUTES.INSIGHTS.getRoute(lastDashboardID);
}

return ROUTES.INSIGHTS.getRoute(CONST.INSIGHTS.DASHBOARD.SPEND);
return DEFAULT_INSIGHTS_TAB_ROUTE;
}

export default getInsightsTabRoute;
export {DEFAULT_INSIGHTS_TAB_ROUTE};
Loading
Loading