Skip to content

The open alternative to Salesforce, designed for AI.

Make the navigation tabs reachable when collapsed and on mobile (#25458)

Félix Malfait7fa7aec3d492
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatCloseButton.tsx b/packages/twenty-front/src/modules/ai/components/AiChatCloseButton.tsx
index ec4b0e454a6..563b809d999 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatCloseButton.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatCloseButton.tsx
@@ -6,7 +6,13 @@ import { useReturnFromExpandedAiChat } from '@/ai/hooks/useReturnFromExpandedAiC
import { isWelcomeAnimationVisibleState } from '@/onboarding/states/isWelcomeAnimationVisibleState';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-export const AiChatCloseButton = () => {
+type AiChatCloseButtonProps = {
+ variant?: 'primary' | 'secondary';
+};
+
+export const AiChatCloseButton = ({
+ variant = 'secondary',
+}: AiChatCloseButtonProps) => {
const { t } = useLingui();
const returnFromExpandedAiChat = useReturnFromExpandedAiChat({
reopenSidePanel: false,
@@ -19,7 +25,7 @@ export const AiChatCloseButton = () => {
<IconButton
Icon={IconX}
size="small"
- variant="secondary"
+ variant={variant}
disabled={isWelcomeAnimationVisible}
onClick={returnFromExpandedAiChat}
ariaLabel={t`Close`}
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatPageHeader.tsx b/packages/twenty-front/src/modules/ai/components/AiChatPageHeader.tsx
index 301804f6dba..e2ba9159bec 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatPageHeader.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatPageHeader.tsx
@@ -71,8 +71,17 @@ export const AiChatPageHeader = ({ isOnboarding }: AiChatPageHeaderProps) => {
ariaLabel={t`New conversation`}
/>
)}
- <AiChatCollapseButton />
- {isOnboarding && <AiChatCloseButton />}
+ {/* Collapsing back into the side panel is a desktop notion; on mobile
+ the page is left outright, so it closes the way the side panel does,
+ down to the same button. */}
+ {isMobile ? (
+ <AiChatCloseButton variant="primary" />
+ ) : (
+ <>
+ <AiChatCollapseButton />
+ {isOnboarding && <AiChatCloseButton />}
+ </>
+ )}
</StyledHeader>
);
};
diff --git a/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx b/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx
index 876195ac20b..519cb96f51b 100644
--- a/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx
@@ -24,9 +24,13 @@ export const AppNavigationDrawer = ({
return (
<NavigationDrawer className={className}>
- <NavigationDrawerFixedContent>
- <MainNavigationDrawerModeSwitcher />
- </NavigationDrawerFixedContent>
+ {/* Mobile switches modes from the navigation bar at the bottom of the
+ screen, so a second switcher inside the drawer only repeats it. */}
+ {!isMobile && (
+ <NavigationDrawerFixedContent>
+ <MainNavigationDrawerModeSwitcher />
+ </NavigationDrawerFixedContent>
+ )}
{isSettingsDrawer ? (
<SettingsNavigationDrawerContent />
diff --git a/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerContent.tsx b/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerContent.tsx
index c72ea0ab8a4..4bdb426e733 100644
--- a/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerContent.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerContent.tsx
@@ -1,6 +1,7 @@
import { MainNavigationDrawerNavigationContent } from '@/navigation/components/MainNavigationDrawerNavigationContent';
import { NavigationDrawerTabbedContent } from '@/navigation/components/NavigationDrawerTabbedContent';
import { useActiveNavigationDrawerMode } from '@/navigation/hooks/useActiveNavigationDrawerMode';
+import { useIsNavigationDrawerContentExpanded } from '@/navigation/hooks/useIsNavigationDrawerContentExpanded';
import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFlag';
import { NavigationDrawerScrollableContent } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerScrollableContent';
import { NAVIGATION_DRAWER_TABS } from '@/ui/navigation/states/navigationDrawerTabs';
@@ -9,8 +10,12 @@ import { PermissionFlagType } from '~/generated-metadata/graphql';
export const MainNavigationDrawerContent = () => {
const activeNavigationDrawerMode = useActiveNavigationDrawerMode();
const hasAiPermission = useHasPermissionFlag(PermissionFlagType.AI);
+ const isExpanded = useIsNavigationDrawerContentExpanded();
+ // Chat threads carry no icon of their own, so the icon rail would list them
+ // as a column of identical bubbles. The navigation items stay useful there.
const showAiChatContent =
+ isExpanded &&
hasAiPermission &&
activeNavigationDrawerMode === NAVIGATION_DRAWER_TABS.AI_CHAT_HISTORY;
diff --git a/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerModeSwitcher.tsx b/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerModeSwitcher.tsx
index 62048f3bf8f..33622e804be 100644
--- a/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerModeSwitcher.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerModeSwitcher.tsx
@@ -1,45 +1,45 @@
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { motion, useReducedMotion } from 'framer-motion';
-import { useContext } from 'react';
-import {
- type IconComponent,
- IconComment,
- IconHome,
- IconSettings,
-} from 'twenty-ui/icon';
+import { useContext, useId } from 'react';
+import { AppTooltip, TooltipDelay, TooltipPosition } from 'twenty-ui/surfaces';
import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
import { useActiveNavigationDrawerMode } from '@/navigation/hooks/useActiveNavigationDrawerMode';
+import { useIsNavigationDrawerContentExpanded } from '@/navigation/hooks/useIsNavigationDrawerContentExpanded';
+import { useNavigationDrawerModes } from '@/navigation/hooks/useNavigationDrawerModes';
import { useSwitchNavigationDrawerMode } from '@/navigation/hooks/useSwitchNavigationDrawerMode';
-import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFlag';
-import { useIsWorkspaceActivationStatusEqualsTo } from '@/workspace/hooks/useIsWorkspaceActivationStatusEqualsTo';
-import { NavigationDrawerAnimatedCollapseWrapper } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerAnimatedCollapseWrapper';
-import {
- type NavigationDrawerActiveTab,
- NAVIGATION_DRAWER_TABS,
-} from '@/ui/navigation/states/navigationDrawerTabs';
-import { WorkspaceActivationStatus } from 'twenty-shared/workspace';
-import { PermissionFlagType } from '~/generated-metadata/graphql';
+import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
-// Sized off the page card header row beside it, so the rules read as one line
-// across both columns.
-const StyledSwitcher = styled.div`
- align-items: center;
- border-bottom: 1px solid ${themeCssVariables.border.color.light};
- border-top: 1px solid ${themeCssVariables.border.color.light};
+// Expanded, the row is sized off the page card header beside it so the rules
+// read as one line across both columns. Collapsed, the modes stack into the
+// icon rail and the rules would cut it in half, so they go.
+const StyledSwitcher = styled.div<{ isExpanded: boolean }>`
+ align-items: ${({ isExpanded }) => (isExpanded ? 'center' : 'flex-start')};
+ border-bottom: ${({ isExpanded }) =>
+ isExpanded ? `1px solid ${themeCssVariables.border.color.light}` : 'none'};
+ border-top: ${({ isExpanded }) =>
+ isExpanded ? `1px solid ${themeCssVariables.border.color.light}` : 'none'};
box-sizing: border-box;
display: flex;
- gap: ${themeCssVariables.spacing['0.5']};
- height: ${themeCssVariables.spacing[10]};
+ flex-direction: ${({ isExpanded }) => (isExpanded ? 'row' : 'column')};
+ gap: ${({ isExpanded }) =>
+ isExpanded
+ ? themeCssVariables.spacing['0.5']
+ : themeCssVariables.betweenSiblingsGap};
+ height: ${({ isExpanded }) =>
+ isExpanded ? themeCssVariables.spacing[10] : 'auto'};
`;
-const StyledMode = styled.button<{ isActive: boolean }>`
+const StyledMode = styled.button<{ isActive: boolean; isExpanded: boolean }>`
align-items: center;
background: ${({ isActive }) =>
isActive ? themeCssVariables.background.transparent.light : 'transparent'};
border: none;
- border-radius: ${themeCssVariables.border.radius.smRound};
+ border-radius: ${({ isExpanded }) =>
+ isExpanded
+ ? themeCssVariables.border.radius.smRound
+ : themeCssVariables.border.radius.mdRound};
color: ${({ isActive }) =>
isActive
? themeCssVariables.font.color.primary
@@ -51,13 +51,19 @@ const StyledMode = styled.button<{ isActive: boolean }>`
font-family: inherit;
font-size: ${themeCssVariables.font.size.md};
font-weight: ${themeCssVariables.font.weight.medium};
- gap: ${({ isActive }) => (isActive ? themeCssVariables.spacing[1] : '0')};
+ gap: ${({ isActive, isExpanded }) =>
+ isActive && isExpanded ? themeCssVariables.spacing[1] : '0'};
height: ${themeCssVariables.spacing[7]};
- padding: 0 ${themeCssVariables.spacing['1.5']};
+ justify-content: ${({ isExpanded }) =>
+ isExpanded ? 'flex-start' : 'center'};
+ padding: ${({ isExpanded }) =>
+ isExpanded ? `0 ${themeCssVariables.spacing['1.5']}` : '0'};
transition:
background calc(${themeCssVariables.animation.duration.fast} * 1s) ease,
color calc(${themeCssVariables.animation.duration.fast} * 1s) ease,
gap calc(${themeCssVariables.animation.duration.normal} * 1s) ease;
+ width: ${({ isExpanded }) =>
+ isExpanded ? 'auto' : themeCssVariables.spacing[6]};
&:hover {
background: ${({ isActive }) =>
@@ -85,57 +91,31 @@ const StyledModeLabelBase = styled.span`
const StyledModeLabel = motion.create(StyledModeLabelBase);
-type NavigationDrawerMode = {
- Icon: IconComponent;
- label: string;
- mode: NavigationDrawerActiveTab;
-};
-
export const MainNavigationDrawerModeSwitcher = () => {
const { t } = useLingui();
const { theme } = useContext(ThemeContext);
+ const tooltipId = useId();
- const hasAiPermission = useHasPermissionFlag(PermissionFlagType.AI);
+ const isMobile = useIsMobile();
+ const isExpanded = useIsNavigationDrawerContentExpanded();
+ const modes = useNavigationDrawerModes();
const activeNavigationDrawerMode = useActiveNavigationDrawerMode();
const { switchNavigationDrawerMode } = useSwitchNavigationDrawerMode();
const shouldReduceMotion = useReducedMotion();
- const isWorkspaceSuspended = useIsWorkspaceActivationStatusEqualsTo(
- WorkspaceActivationStatus.SUSPENDED,
- );
-
- // A suspended workspace is held on the billing settings by the route guard,
- // so offering the modes it would bounce back from only flashes the user out
- // and in again.
- if (isWorkspaceSuspended) {
+ if (modes.length === 0) {
return null;
}
- const modes: NavigationDrawerMode[] = [
- {
- Icon: IconHome,
- label: t`Home`,
- mode: NAVIGATION_DRAWER_TABS.NAVIGATION_MENU,
- },
- ...(hasAiPermission
- ? [
- {
- Icon: IconComment,
- label: t`AI`,
- mode: NAVIGATION_DRAWER_TABS.AI_CHAT_HISTORY,
- },
- ]
- : []),
- {
- Icon: IconSettings,
- label: t`Settings`,
- mode: NAVIGATION_DRAWER_TABS.SETTINGS,
- },
- ];
+ const shouldShowTooltips = !isExpanded && !isMobile;
return (
- <NavigationDrawerAnimatedCollapseWrapper>
- <StyledSwitcher role="group" aria-label={t`Navigation modes`}>
+ <>
+ <StyledSwitcher
+ isExpanded={isExpanded}
+ role="group"
+ aria-label={t`Navigation modes`}
+ >
{modes.map(({ Icon, label, mode }) => {
const isActive = mode === activeNavigationDrawerMode;
@@ -143,7 +123,9 @@ export const MainNavigationDrawerModeSwitcher = () => {
<StyledMode
key={mode}
type="button"
+ data-tooltip-id={`${tooltipId}-${mode}`}
isActive={isActive}
+ isExpanded={isExpanded}
aria-label={label}
aria-current={isActive}
onClick={() => switchNavigationDrawerMode(mode)}
@@ -153,7 +135,7 @@ export const MainNavigationDrawerModeSwitcher = () => {
</StyledModeIcon>
<StyledModeLabel
initial={false}
- animate={{ width: isActive ? 'auto' : 0 }}
+ animate={{ width: isExpanded && isActive ? 'auto' : 0 }}
transition={{
duration: shouldReduceMotion
? 0
@@ -167,6 +149,18 @@ export const MainNavigationDrawerModeSwitcher = () => {
);
})}
</StyledSwitcher>
- </NavigationDrawerAnimatedCollapseWrapper>
+ {shouldShowTooltips &&
+ modes.map(({ label, mode }) => (
+ <AppTooltip
+ key={mode}
+ anchorSelect={`[data-tooltip-id='${tooltipId}-${mode}']`}
+ content={label}
+ delay={TooltipDelay.noDelay}
+ place={TooltipPosition.Right}
+ positionStrategy="fixed"
+ noArrow
+ />
+ ))}
+ </>
);
};
diff --git a/packages/twenty-front/src/modules/navigation/components/MobileNavigationBar.tsx b/packages/twenty-front/src/modules/navigation/components/MobileNavigationBar.tsx
index 182342c8932..771a5204b32 100644
--- a/packages/twenty-front/src/modules/navigation/components/MobileNavigationBar.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/MobileNavigationBar.tsx
@@ -1,12 +1,14 @@
import { MobileNavigationBarScrollEffect } from '@/navigation/components/MobileNavigationBarScrollEffect';
+import { MOBILE_NAVIGATION_BAR_PADDING } from '@/navigation/constants/MobileNavigationBarPadding';
import { useMobileNavigationBarItems } from '@/navigation/hooks/useMobileNavigationBarItems';
import { isMobileNavigationBarVisibleState } from '@/navigation/states/isMobileNavigationBarVisibleState';
import { isSidePanelOpenedState } from '@/side-panel/states/isSidePanelOpenedState';
import { RootStackingContextZIndices } from '@/ui/layout/constants/RootStackingContextZIndices';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { styled } from '@linaria/react';
+import { useLocation } from 'react-router-dom';
import { NavigationBar } from 'twenty-ui/navigation';
-import { themeCssVariables } from 'twenty-ui/theme-constants';
+import { isAiChatPath } from '~/utils/isAiChatPath';
// The bar floats over the page, so the container has to let taps through to
// whatever is scrolling underneath it. flex-start rather than left so the bar
@@ -16,9 +18,9 @@ const StyledFloatingContainer = styled.div`
display: flex;
justify-content: flex-start;
left: 0;
- padding: ${themeCssVariables.spacing[3]};
+ padding: ${MOBILE_NAVIGATION_BAR_PADDING};
padding-bottom: calc(
- ${themeCssVariables.spacing[3]} + env(safe-area-inset-bottom, 0px)
+ ${MOBILE_NAVIGATION_BAR_PADDING} + env(safe-area-inset-bottom, 0px)
);
pointer-events: none;
position: absolute;
@@ -35,13 +37,19 @@ const StyledFloatingContainer = styled.div`
`;
export const MobileNavigationBar = () => {
+ const { pathname } = useLocation();
const isSidePanelOpened = useAtomStateValue(isSidePanelOpenedState);
const isMobileNavigationBarVisible = useAtomStateValue(
isMobileNavigationBarVisibleState,
);
const { items, activeItemName } = useMobileNavigationBarItems();
- const isHidden = isSidePanelOpened || !isMobileNavigationBarVisible;
+ // The chat page keeps the keyboard up most of the time, which leaves no room
+ // for the bar, and it carries its own close button to leave by.
+ const isHidden =
+ isSidePanelOpened ||
+ !isMobileNavigationBarVisible ||
+ isAiChatPath(pathname);
return (
<>
diff --git a/packages/twenty-front/src/modules/navigation/components/SettingsNavigationDrawerContent.tsx b/packages/twenty-front/src/modules/navigation/components/SettingsNavigationDrawerContent.tsx
index 7a46a001538..d1f0c976d8a 100644
--- a/packages/twenty-front/src/modules/navigation/components/SettingsNavigationDrawerContent.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/SettingsNavigationDrawerContent.tsx
@@ -1,3 +1,4 @@
+import { MOBILE_NAVIGATION_BAR_CLEARANCE } from '@/navigation/constants/MobileNavigationBarClearance';
import { SettingsNavigationDrawerItems } from '@/settings/components/SettingsNavigationDrawerItems';
import { NavigationDrawerScrollableContent } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerScrollableContent';
import { NavigationDrawerSection } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSection';
@@ -13,6 +14,8 @@ import { useIsMobile } from 'twenty-ui/utilities';
const StyledAdvancedToggleFixedContent = styled.div<{ isMobile: boolean }>`
flex-shrink: 0;
margin-top: auto;
+ padding-bottom: ${({ isMobile }) =>
+ isMobile ? MOBILE_NAVIGATION_BAR_CLEARANCE : '0'};
padding-left: ${({ isMobile }) =>
isMobile ? themeCssVariables.spacing[5] : '0'};
padding-right: ${({ isMobile }) =>
diff --git a/packages/twenty-front/src/modules/navigation/components/__tests__/AppNavigationDrawer.test.tsx b/packages/twenty-front/src/modules/navigation/components/__tests__/AppNavigationDrawer.test.tsx
index 2ca682acfc4..3a2d2e7c175 100644
--- a/packages/twenty-front/src/modules/navigation/components/__tests__/AppNavigationDrawer.test.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/__tests__/AppNavigationDrawer.test.tsx
@@ -61,4 +61,16 @@ describe('AppNavigationDrawer', () => {
modeSwitcher,
);
});
+
+ it('leaves mode switching to the navigation bar on mobile', () => {
+ jest.mocked(useIsMobile).mockReturnValue(true);
+ jest.mocked(useIsSettingsDrawer).mockReturnValue(true);
+
+ render(<AppNavigationDrawer />);
+
+ expect(screen.getByText('Settings content')).toBeInTheDocument();
+ expect(
+ screen.queryByRole('button', { name: 'Navigation modes' }),
+ ).not.toBeInTheDocument();
+ });
});
diff --git a/packages/twenty-front/src/modules/navigation/components/__tests__/MainNavigationDrawerModeSwitcher.test.tsx b/packages/twenty-front/src/modules/navigation/components/__tests__/MainNavigationDrawerModeSwitcher.test.tsx
new file mode 100644
index 00000000000..0b3c9b050ca
--- /dev/null
+++ b/packages/twenty-front/src/modules/navigation/components/__tests__/MainNavigationDrawerModeSwitcher.test.tsx
@@ -0,0 +1,99 @@
+import { MainNavigationDrawerModeSwitcher } from '@/navigation/components/MainNavigationDrawerModeSwitcher';
+import { useActiveNavigationDrawerMode } from '@/navigation/hooks/useActiveNavigationDrawerMode';
+import { useIsNavigationDrawerContentExpanded } from '@/navigation/hooks/useIsNavigationDrawerContentExpanded';
+import { useNavigationDrawerModes } from '@/navigation/hooks/useNavigationDrawerModes';
+import { useSwitchNavigationDrawerMode } from '@/navigation/hooks/useSwitchNavigationDrawerMode';
+import { NAVIGATION_DRAWER_TABS } from '@/ui/navigation/states/navigationDrawerTabs';
+import { i18n } from '@lingui/core';
+import { I18nProvider } from '@lingui/react';
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { IconComment, IconHome, IconSettings } from 'twenty-ui/icon';
+
+jest.mock('@/navigation/hooks/useActiveNavigationDrawerMode');
+jest.mock('@/navigation/hooks/useIsNavigationDrawerContentExpanded');
+jest.mock('@/navigation/hooks/useNavigationDrawerModes');
+jest.mock('@/navigation/hooks/useSwitchNavigationDrawerMode');
+
+jest.mock('@/ui/utilities/responsive/hooks/useIsMobile', () => ({
+ useIsMobile: () => false,
+}));
+
+jest.mock('twenty-ui/surfaces', () => ({
+ ...jest.requireActual('twenty-ui/surfaces'),
+ AppTooltip: () => null,
+}));
+
+const mockSwitchNavigationDrawerMode = jest.fn();
+
+const renderModeSwitcher = () =>
+ render(
+ <I18nProvider i18n={i18n}>
+ <MainNavigationDrawerModeSwitcher />
+ </I18nProvider>,
+ );
+
+describe('MainNavigationDrawerModeSwitcher', () => {
+ beforeEach(() => {
+ jest.clearAllMocks();
+
+ jest.mocked(useNavigationDrawerModes).mockReturnValue([
+ {
+ Icon: IconHome,
+ label: 'Home',
+ mode: NAVIGATION_DRAWER_TABS.NAVIGATION_MENU,
+ },
+ {
+ Icon: IconComment,
+ label: 'AI',
+ mode: NAVIGATION_DRAWER_TABS.AI_CHAT_HISTORY,
+ },
+ {
+ Icon: IconSettings,
+ label: 'Settings',
+ mode: NAVIGATION_DRAWER_TABS.SETTINGS,
+ },
+ ]);
+ jest
+ .mocked(useActiveNavigationDrawerMode)
+ .mockReturnValue(NAVIGATION_DRAWER_TABS.NAVIGATION_MENU);
+ jest.mocked(useSwitchNavigationDrawerMode).mockReturnValue({
+ switchNavigationDrawerMode: mockSwitchNavigationDrawerMode,
+ });
+ jest.mocked(useIsNavigationDrawerContentExpanded).mockReturnValue(true);
+ });
+
+ it('switches mode from the collapsed icon rail', async () => {
+ jest.mocked(useIsNavigationDrawerContentExpanded).mockReturnValue(false);
+
+ renderModeSwitcher();
+
+ await userEvent.click(screen.getByRole('button', { name: 'AI' }));
+
+ expect(mockSwitchNavigationDrawerMode).toHaveBeenCalledTimes(1);
+ expect(mockSwitchNavigationDrawerMode).toHaveBeenCalledWith(
+ NAVIGATION_DRAWER_TABS.AI_CHAT_HISTORY,
+ );
+ });
+
+ it('switches mode from the expanded row', async () => {
+ renderModeSwitcher();
+
+ await userEvent.click(screen.getByRole('button', { name: 'Settings' }));
+
+ expect(mockSwitchNavigationDrawerMode).toHaveBeenCalledTimes(1);
+ expect(mockSwitchNavigationDrawerMode).toHaveBeenCalledWith(
+ NAVIGATION_DRAWER_TABS.SETTINGS,
+ );
+ });
+
+ it('renders nothing when no mode is available', () => {
+ jest.mocked(useNavigationDrawerModes).mockReturnValue([]);
+
+ renderModeSwitcher();
+
+ expect(
+ screen.queryByRole('group', { name: 'Navigation modes' }),
+ ).not.toBeInTheDocument();
+ });
+});
diff --git a/packages/twenty-front/src/modules/navigation/components/__tests__/MobileNavigationBar.test.tsx b/packages/twenty-front/src/modules/navigation/components/__tests__/MobileNavigationBar.test.tsx
new file mode 100644
index 00000000000..5e0352fe1d9
--- /dev/null
+++ b/packages/twenty-front/src/modules/navigation/components/__tests__/MobileNavigationBar.test.tsx
@@ -0,0 +1,50 @@
+import { MobileNavigationBar } from '@/navigation/components/MobileNavigationBar';
+import { useMobileNavigationBarItems } from '@/navigation/hooks/useMobileNavigationBarItems';
+import { render, screen } from '@testing-library/react';
+import { createStore, Provider } from 'jotai';
+import { MemoryRouter } from 'react-router-dom';
+import { IconHome } from 'twenty-ui/icon';
+
+jest.mock('@/navigation/hooks/useMobileNavigationBarItems');
+
+jest.mock('@/navigation/components/MobileNavigationBarScrollEffect', () => ({
+ MobileNavigationBarScrollEffect: () => null,
+}));
+
+const renderMobileNavigationBar = (pathname: string) =>
+ render(
+ <Provider store={createStore()}>
+ <MemoryRouter initialEntries={[pathname]}>
+ <MobileNavigationBar />
+ </MemoryRouter>
+ </Provider>,
+ );
+
+describe('MobileNavigationBar', () => {
+ beforeEach(() => {
+ jest.mocked(useMobileNavigationBarItems).mockReturnValue({
+ activeItemName: 'home',
+ items: [
+ { name: 'home', label: 'Home', Icon: IconHome, onClick: jest.fn() },
+ ],
+ });
+ });
+
+ it('shows the bar on the home page', () => {
+ renderMobileNavigationBar('/home');
+
+ expect(screen.getByRole('navigation')).not.toHaveAttribute(
+ 'aria-hidden',
+ 'true',
+ );
+ });
+
+ it('hides the bar on the chat page', () => {
+ renderMobileNavigationBar('/chat/20202020-0687-4c41-b707-ed1bfca972a7');
+
+ expect(screen.getByRole('navigation', { hidden: true })).toHaveAttribute(
+ 'aria-hidden',
+ 'true',
+ );
+ });
+});
diff --git a/packages/twenty-front/src/modules/navigation/constants/MobileNavigationBarClearance.ts b/packages/twenty-front/src/modules/navigation/constants/MobileNavigationBarClearance.ts
new file mode 100644
index 00000000000..0faca95e46a
--- /dev/null
+++ b/packages/twenty-front/src/modules/navigation/constants/MobileNavigationBarClearance.ts
@@ -0,0 +1,6 @@
+import { MOBILE_NAVIGATION_BAR_HEIGHT } from '@/navigation/constants/MobileNavigationBarHeight';
+import { MOBILE_NAVIGATION_BAR_PADDING } from '@/navigation/constants/MobileNavigationBarPadding';
+
+// The bar floats over the page, so a surface that pins content to the bottom
+// has to reserve what it covers.
+export const MOBILE_NAVIGATION_BAR_CLEARANCE = `calc(${MOBILE_NAVIGATION_BAR_HEIGHT} + 2 * ${MOBILE_NAVIGATION_BAR_PADDING} + env(safe-area-inset-bottom, 0px))`;
diff --git a/packages/twenty-front/src/modules/navigation/constants/MobileNavigationBarHeight.ts b/packages/twenty-front/src/modules/navigation/constants/MobileNavigationBarHeight.ts
new file mode 100644
index 00000000000..5444e9eebfb
--- /dev/null
+++ b/packages/twenty-front/src/modules/navigation/constants/MobileNavigationBarHeight.ts
@@ -0,0 +1,5 @@
+import { themeCssVariables } from 'twenty-ui/theme-constants';
+
+// NavigationBar builds its row out of the item height plus its own padding and
+// border, so the height has to be rebuilt from the same tokens here.
+export const MOBILE_NAVIGATION_BAR_HEIGHT = `calc(${themeCssVariables.spacing[10]} + 2 * ${themeCssVariables.spacing[1]} + 2px)`;
diff --git a/packages/twenty-front/src/modules/navigation/constants/MobileNavigationBarPadding.ts b/packages/twenty-front/src/modules/navigation/constants/MobileNavigationBarPadding.ts
new file mode 100644
index 00000000000..3613c20a4ae
--- /dev/null
+++ b/packages/twenty-front/src/modules/navigation/constants/MobileNavigationBarPadding.ts
@@ -0,0 +1,3 @@
+import { themeCssVariables } from 'twenty-ui/theme-constants';
+
+export const MOBILE_NAVIGATION_BAR_PADDING = themeCssVariables.spacing[3];
diff --git a/packages/twenty-front/src/modules/navigation/hooks/__tests__/useMobileNavigationBarItems.test.tsx b/packages/twenty-front/src/modules/navigation/hooks/__tests__/useMobileNavigationBarItems.test.tsx
new file mode 100644
index 00000000000..08c81fbf42b
--- /dev/null
+++ b/packages/twenty-front/src/modules/navigation/hooks/__tests__/useMobileNavigationBarItems.test.tsx
@@ -0,0 +1,140 @@
+import { useSwitchToNewAiChat } from '@/ai/hooks/useSwitchToNewAiChat';
+import { useMobileNavigationBarItems } from '@/navigation/hooks/useMobileNavigationBarItems';
+import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFlag';
+import { i18n } from '@lingui/core';
+import { I18nProvider } from '@lingui/react';
+import { act, renderHook } from '@testing-library/react';
+import { createStore, Provider } from 'jotai';
+import { type ReactNode } from 'react';
+import { MemoryRouter, useLocation, useNavigate } from 'react-router-dom';
+
+jest.mock('@/ai/hooks/useSwitchToNewAiChat');
+jest.mock('@/settings/roles/hooks/useHasPermissionFlag');
+
+jest.mock('@/object-metadata/hooks/useFilteredObjectMetadataItems', () => ({
+ useFilteredObjectMetadataItems: () => ({
+ alphaSortedActiveNonSystemObjectMetadataItems: [],
+ }),
+}));
+
+jest.mock('@/side-panel/hooks/useOpenRecordsSearchPageInSidePanel', () => ({
+ useOpenRecordsSearchPageInSidePanel: () => ({
+ openRecordsSearchPage: jest.fn(),
+ }),
+}));
+
+jest.mock('@/side-panel/hooks/useSidePanelMenu', () => ({
+ useSidePanelMenu: () => ({ closeSidePanelMenu: jest.fn() }),
+}));
+
+const mockSwitchToNewChat = jest.fn();
+
+const renderMobileNavigationBarItems = (
+ pathname: string,
+ previousPathnames: string[] = [],
+) => {
+ const store = createStore();
+
+ const { result } = renderHook(
+ () => ({
+ ...useMobileNavigationBarItems(),
+ location: useLocation(),
+ navigate: useNavigate(),
+ }),
+ {
+ wrapper: ({ children }: { children: ReactNode }) => (
+ <I18nProvider i18n={i18n}>
+ <Provider store={store}>
+ <MemoryRouter initialEntries={[...previousPathnames, pathname]}>
+ {children}
+ </MemoryRouter>
+ </Provider>
+ </I18nProvider>
+ ),
+ },
+ );
+
+ return { result, store };
+};
+
+const tapItem = (
+ result: { current: { items: { name: string; onClick: () => void }[] } },
+ name: string,
+) => result.current.items.find((item) => item.name === name)?.onClick();
+
+describe('useMobileNavigationBarItems', () => {
+ beforeEach(() => {
+ jest.clearAllMocks();
+ localStorage.clear();
+
+ jest.mocked(useHasPermissionFlag).mockReturnValue(true);
+ jest.mocked(useSwitchToNewAiChat).mockReturnValue({
+ switchToNewChat: mockSwitchToNewChat,
+ });
+ });
+
+ it('offers home, search and a new chat', () => {
+ const { result } = renderMobileNavigationBarItems('/objects/people');
+
+ expect(result.current.items.map(({ name }) => name)).toEqual([
+ 'home',
+ 'search',
+ 'newAiChat',
+ ]);
+ });
+
+ it('drops the new chat when the workspace has no AI permission', () => {
+ jest.mocked(useHasPermissionFlag).mockReturnValue(false);
+
+ const { result } = renderMobileNavigationBarItems('/objects/people');
+
+ expect(result.current.items.map(({ name }) => name)).toEqual([
+ 'home',
+ 'search',
+ ]);
+ });
+
+ it('marks home as active on the home page only', () => {
+ expect(
+ renderMobileNavigationBarItems('/home').result.current.activeItemName,
+ ).toBe('home');
+ expect(
+ renderMobileNavigationBarItems('/objects/people').result.current
+ .activeItemName,
+ ).toBe('');
+ });
+
+ it('starts a new chat from the chat item', () => {
+ const { result } = renderMobileNavigationBarItems('/objects/people');
+
+ act(() => tapItem(result, 'newAiChat'));
+
+ expect(mockSwitchToNewChat).toHaveBeenCalledTimes(1);
+ });
+
+ it('replaces the settings entry it leaves so back does not return to it', () => {
+ const { result } = renderMobileNavigationBarItems('/settings/profile', [
+ '/objects/people',
+ ]);
+
+ act(() => tapItem(result, 'home'));
+
+ expect(result.current.location.pathname).toBe('/home');
+
+ act(() => result.current.navigate(-1));
+
+ expect(result.current.location.pathname).toBe('/objects/people');
+ });
+
+ it('keeps the page it leaves in history outside of settings', () => {
+ const { result } = renderMobileNavigationBarItems('/objects/people');
+
+ act(() => tapItem(result, 'home'));
+
+ expect(result.current.location.pathname).toBe('/home');
+
+ act(() => result.current.navigate(-1));
+
+ expect(result.current.location.pathname).toBe('/objects/people');
+ });
+});
diff --git a/packages/twenty-front/src/modules/navigation/hooks/__tests__/useSwitchNavigationDrawerMode.test.tsx b/packages/twenty-front/src/modules/navigation/hooks/__tests__/useSwitchNavigationDrawerMode.test.tsx
index 0fe42aeb6e3..8f440ff45d9 100644
--- a/packages/twenty-front/src/modules/navigation/hooks/__tests__/useSwitchNavigationDrawerMode.test.tsx
+++ b/packages/twenty-front/src/modules/navigation/hooks/__tests__/useSwitchNavigationDrawerMode.test.tsx
@@ -2,11 +2,13 @@ import { useReturnFromExpandedAiChat } from '@/ai/hooks/useReturnFromExpandedAiC
import { useSwitchToNewAiChat } from '@/ai/hooks/useSwitchToNewAiChat';
import { useDefaultHomePagePath } from '@/navigation/hooks/useDefaultHomePagePath';
import { useSwitchNavigationDrawerMode } from '@/navigation/hooks/useSwitchNavigationDrawerMode';
+import { currentMobileNavigationDrawerState } from '@/navigation/states/currentMobileNavigationDrawerState';
import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
import { navigationDrawerActiveTabState } from '@/ui/navigation/states/navigationDrawerActiveTabState';
import { navigationDrawerExpandedMemorizedState } from '@/ui/navigation/states/navigationDrawerExpandedMemorizedState';
import { NAVIGATION_DRAWER_TABS } from '@/ui/navigation/states/navigationDrawerTabs';
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
+import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
import { act, renderHook } from '@testing-library/react';
import { createStore, Provider } from 'jotai';
import { type ReactNode } from 'react';
@@ -15,6 +17,7 @@ import { MemoryRouter, useLocation } from 'react-router-dom';
jest.mock('@/ai/hooks/useReturnFromExpandedAiChat');
jest.mock('@/ai/hooks/useSwitchToNewAiChat');
jest.mock('@/navigation/hooks/useDefaultHomePagePath');
+jest.mock('@/ui/utilities/responsive/hooks/useIsMobile');
const DEFAULT_HOME_PAGE_PATH = '/objects/companies';
const AI_CHAT_PATH = '/chat/20202020-0687-4c41-b707-ed1bfca972a7';
@@ -26,16 +29,19 @@ const renderSwitchNavigationDrawerMode = ({
pathname,
memorizedUrl = '/objects/people',
expandedMemorized = true,
+ mobileNavigationDrawer = 'main',
}: {
pathname: string;
memorizedUrl?: string;
expandedMemorized?: boolean;
+ mobileNavigationDrawer?: 'main' | 'settings';
}) => {
const store = createStore();
store.set(navigationMemorizedUrlState.atom, memorizedUrl);
store.set(navigationDrawerExpandedMemorizedState.atom, expandedMemorized);
store.set(isNavigationDrawerExpandedState.atom, true);
+ store.set(currentMobileNavigationDrawerState.atom, mobileNavigationDrawer);
const { result } = renderHook(
() => ({
@@ -68,6 +74,7 @@ describe('useSwitchNavigationDrawerMode', () => {
jest.mocked(useDefaultHomePagePath).mockReturnValue({
defaultHomePagePath: DEFAULT_HOME_PAGE_PATH,
});
+ jest.mocked(useIsMobile).mockReturnValue(false);
});
it('leaves settings for the memorized location and restores the drawer', () => {
@@ -189,6 +196,23 @@ describe('useSwitchNavigationDrawerMode', () => {
);
});
+ it('opens settings from a page the mobile drawer only thinks is settings', () => {
+ jest.mocked(useIsMobile).mockReturnValue(true);
+
+ const { result } = renderSwitchNavigationDrawerMode({
+ pathname: '/objects/people',
+ mobileNavigationDrawer: 'settings',
+ });
+
+ act(() =>
+ result.current.switchNavigationDrawerMode(
+ NAVIGATION_DRAWER_TABS.SETTINGS,
+ ),
+ );
+
+ expect(result.current.location.pathname).toBe('/settings/profile');
+ });
+
it('stays put when settings is already open', () => {
const { result } = renderSwitchNavigationDrawerMode({
pathname: '/settings/experience',
diff --git a/packages/twenty-front/src/modules/navigation/hooks/useMobileNavigationBarItems.ts b/packages/twenty-front/src/modules/navigation/hooks/useMobileNavigationBarItems.ts
index c7debe398a4..5f44077dca1 100644
--- a/packages/twenty-front/src/modules/navigation/hooks/useMobileNavigationBarItems.ts
+++ b/packages/twenty-front/src/modules/navigation/hooks/useMobileNavigationBarItems.ts
@@ -80,7 +80,10 @@ export const useMobileNavigationBarItems = (): {
onClick: () => {
closeSidePanelMenu();
closeSettingsDrawer();
- navigate(AppPath.Home);
+ // Leaving settings replaces its entry the way desktop does, so that
+ // going back does not drop the user straight into the settings they
+ // just left.
+ navigate(AppPath.Home, { replace: isSettingsDrawer });
},
},
{
diff --git a/packages/twenty-front/src/modules/navigation/hooks/useNavigationDrawerModes.ts b/packages/twenty-front/src/modules/navigation/hooks/useNavigationDrawerModes.ts
new file mode 100644
index 00000000000..e869119677a
--- /dev/null
+++ b/packages/twenty-front/src/modules/navigation/hooks/useNavigationDrawerModes.ts
@@ -0,0 +1,60 @@
+import { useLingui } from '@lingui/react/macro';
+import { WorkspaceActivationStatus } from 'twenty-shared/workspace';
+import {
+ type IconComponent,
+ IconComment,
+ IconHome,
+ IconSettings,
+} from 'twenty-ui/icon';
+
+import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFlag';
+import {
+ type NavigationDrawerActiveTab,
+ NAVIGATION_DRAWER_TABS,
+} from '@/ui/navigation/states/navigationDrawerTabs';
+import { useIsWorkspaceActivationStatusEqualsTo } from '@/workspace/hooks/useIsWorkspaceActivationStatusEqualsTo';
+import { PermissionFlagType } from '~/generated-metadata/graphql';
+
+export type NavigationDrawerMode = {
+ Icon: IconComponent;
+ label: string;
+ mode: NavigationDrawerActiveTab;
+};
+
+export const useNavigationDrawerModes = (): NavigationDrawerMode[] => {
+ const { t } = useLingui();
+
+ const hasAiPermission = useHasPermissionFlag(PermissionFlagType.AI);
+ const isWorkspaceSuspended = useIsWorkspaceActivationStatusEqualsTo(
+ WorkspaceActivationStatus.SUSPENDED,
+ );
+
+ // A suspended workspace is held on the billing settings by the route guard,
+ // so offering the modes it would bounce back from only flashes the user out
+ // and in again.
+ if (isWorkspaceSuspended) {
+ return [];
+ }
+
+ return [
+ {
+ Icon: IconHome,
+ label: t`Home`,
+ mode: NAVIGATION_DRAWER_TABS.NAVIGATION_MENU,
+ },
+ ...(hasAiPermission
+ ? [
+ {
+ Icon: IconComment,
+ label: t`AI`,
+ mode: NAVIGATION_DRAWER_TABS.AI_CHAT_HISTORY,
+ },
+ ]
+ : []),
+ {
+ Icon: IconSettings,
+ label: t`Settings`,
+ mode: NAVIGATION_DRAWER_TABS.SETTINGS,
+ },
+ ];
+};
diff --git a/packages/twenty-front/src/modules/navigation/hooks/useSwitchNavigationDrawerMode.ts b/packages/twenty-front/src/modules/navigation/hooks/useSwitchNavigationDrawerMode.ts
index d5285c17672..55d03d47f3a 100644
--- a/packages/twenty-front/src/modules/navigation/hooks/useSwitchNavigationDrawerMode.ts
+++ b/packages/twenty-front/src/modules/navigation/hooks/useSwitchNavigationDrawerMode.ts
@@ -7,6 +7,7 @@ import { getExpandedAiChatReturnLocation } from '@/ai/utils/getExpandedAiChatRet
import { useActiveNavigationDrawerMode } from '@/navigation/hooks/useActiveNavigationDrawerMode';
import { useDefaultHomePagePath } from '@/navigation/hooks/useDefaultHomePagePath';
import { useIsSettingsDrawer } from '@/navigation/hooks/useIsSettingsDrawer';
+import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage';
import { currentMobileNavigationDrawerState } from '@/navigation/states/currentMobileNavigationDrawerState';
import { getNavigationDrawerHomeDestination } from '@/navigation/utils/getNavigationDrawerHomeDestination';
import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
@@ -29,6 +30,7 @@ export const useSwitchNavigationDrawerMode = () => {
const activeNavigationDrawerMode = useActiveNavigationDrawerMode();
const isSettingsDrawer = useIsSettingsDrawer();
+ const isSettingsPage = useIsSettingsPage();
const isAiChatPage = isAiChatPath(location.pathname);
const navigationMemorizedUrl = useAtomStateValue(navigationMemorizedUrlState);
@@ -103,7 +105,11 @@ export const useSwitchNavigationDrawerMode = () => {
switchToAiChat();
break;
case NAVIGATION_DRAWER_TABS.SETTINGS:
- if (isSettingsDrawer) {
+ // The mobile settings drawer outlives the route that opened it, a
+ // browser back out of settings for one, so the page rather than the
+ // drawer says whether there is anywhere left to go. Desktop has no
+ // such split: there the two are the same thing.
+ if (isSettingsPage) {
return;
}
navigateSettings(SettingsPath.ProfilePage);
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/MultiWorkspaceDropdownButton.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/MultiWorkspaceDropdownButton.tsx
index af38c7e4fdc..04a6d6674af 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/MultiWorkspaceDropdownButton.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/MultiWorkspaceDropdownButton.tsx
@@ -6,7 +6,9 @@ import { MultiWorkspaceDropdownOpenRecordInComponents } from '@/ui/navigation/na
import { MultiWorkspaceDropdownThemesComponents } from '@/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/internal/MultiWorkspaceDropdownThemesComponents';
import { MultiWorkspaceDropdownWorkspacesListComponents } from '@/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/internal/MultiWorkspaceDropdownWorkspacesListComponents';
import { MULTI_WORKSPACE_DROPDOWN_ID } from '@/ui/navigation/navigation-drawer/constants/MultiWorkspaceDropdownId';
+import { MULTI_WORKSPACE_DROPDOWN_MOBILE_BOUNDARY_PADDING } from '@/ui/navigation/navigation-drawer/constants/MultiWorkspaceDropdownMobileBoundaryPadding';
import { multiWorkspaceDropdownState } from '@/ui/navigation/navigation-drawer/states/multiWorkspaceDropdownState';
+import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { useMemo } from 'react';
@@ -24,6 +26,7 @@ export const MultiWorkspaceDropdownButton = ({
const isLayoutCustomizationModeEnabled = useAtomStateValue(
isLayoutCustomizationModeEnabledState,
);
+ const isMobile = useIsMobile();
const DropdownComponents = useMemo(() => {
switch (multiWorkspaceDropdown) {
@@ -41,6 +44,19 @@ export const MultiWorkspaceDropdownButton = ({
return (
<Dropdown
dropdownId={MULTI_WORKSPACE_DROPDOWN_ID}
+ // The trigger spans the whole row so the panel can overlay it. Aligned
+ // to the row's end that lands on the drawer edge on desktop, but on
+ // mobile the row is the full screen and the panel drifted away from the
+ // workspace name it belongs to.
+ dropdownPlacement={isMobile ? 'bottom-start' : 'bottom-end'}
+ middlewareBoundaryPadding={
+ isMobile
+ ? {
+ left: MULTI_WORKSPACE_DROPDOWN_MOBILE_BOUNDARY_PADDING,
+ right: MULTI_WORKSPACE_DROPDOWN_MOBILE_BOUNDARY_PADDING,
+ }
+ : undefined
+ }
dropdownOffset={
// The drawer trigger is full width and the panel sits over it; the
// icon-only trigger is too small for that, so the panel drops below.
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/internal/MultiWorkspaceDropdownDefaultComponents.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/internal/MultiWorkspaceDropdownDefaultComponents.tsx
index 2e0c31f91d7..c0e8f6335fb 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/internal/MultiWorkspaceDropdownDefaultComponents.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/internal/MultiWorkspaceDropdownDefaultComponents.tsx
@@ -33,6 +33,7 @@ import {
IconLogout,
IconMessage,
IconPlus,
+ IconSettings,
IconSwitchHorizontal,
IconUserPlus,
} from 'twenty-ui/icon';
@@ -44,6 +45,7 @@ import {
} from 'twenty-ui/navigation';
import { useIsMobile } from 'twenty-ui/utilities';
import { type AvailableWorkspace } from '~/generated-metadata/graphql';
+import { useNavigateSettings } from '~/hooks/useNavigateSettings';
import { getWorkspaceUrl } from '~/utils/getWorkspaceUrl';
import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';
@@ -72,8 +74,15 @@ export const MultiWorkspaceDropdownDefaultComponents = () => {
);
const { openRecordInPreference } = useOpenRecordInPreference();
+ const navigateSettings = useNavigateSettings();
- const canDisplaySidePanel = !useIsMobile();
+ const isMobile = useIsMobile();
+ const canDisplaySidePanel = !isMobile;
+
+ const handleSettings = () => {
+ closeDropdown(MULTI_WORKSPACE_DROPDOWN_ID);
+ navigateSettings(SettingsPath.ProfilePage);
+ };
const handleSupport = () => {
window.FrontChat?.('show');
@@ -188,6 +197,15 @@ export const MultiWorkspaceDropdownDefaultComponents = () => {
</>
)}
<DropdownMenuItemsContainer>
+ {/* Desktop reaches settings from the drawer's mode switcher, which
+ mobile does not render, so the workspace menu is where it lives. */}
+ {isMobile && (
+ <MenuItem
+ LeftIcon={IconSettings}
+ text={t`Settings`}
+ onClick={handleSettings}
+ />
+ )}
<MenuItem
LeftIcon={colorSchemeList.find(({ id }) => id === colorScheme)?.icon}
text={t`Theme`}
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/constants/MultiWorkspaceDropdownMobileBoundaryPadding.ts b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/constants/MultiWorkspaceDropdownMobileBoundaryPadding.ts
new file mode 100644
index 00000000000..0fc02225c8e
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/constants/MultiWorkspaceDropdownMobileBoundaryPadding.ts
@@ -0,0 +1,4 @@
+// On mobile the page inset is 20px and the panel overlays its trigger 5px to
+// the left, so its edge lands at 16px. The default 32px boundary would make
+// floating-ui flip the alignment and send the panel to the far edge instead.
+export const MULTI_WORKSPACE_DROPDOWN_MOBILE_BOUNDARY_PADDING = 16;