Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(crm): close the narrow CRM navigation menu on collapse (#8219)
teo6862f13626f7
diff --git a/apps/web/src/features/crm/views/crm-workspace.test.tsx b/apps/web/src/features/crm/views/crm-workspace.test.tsxindex 0df382acbc..7c2450c21f 100644--- a/apps/web/src/features/crm/views/crm-workspace.test.tsx+++ b/apps/web/src/features/crm/views/crm-workspace.test.tsx@@ -5,7 +5,7 @@ import {screen,within,} from '@solidjs/testing-library';-import { createSignal, For, type JSX, type ParentProps } from 'solid-js';+import { createSignal, For, type JSX, type ParentProps, Show } from 'solid-js';import { afterEach, expect, it, vi } from 'vitest';import { CrmWorkspaceView } from './crm-workspace';@@ -14,7 +14,9 @@ const fixture = vi.hoisted(() => ({pipelinesEnabled: true,listsEnabled: true,touch: true,+ narrow: false,openWithSplit: vi.fn(),+ setCollapsed: vi.fn(),}));vi.mock('@app/components/view-shell', () => ({@@ -26,13 +28,22 @@ vi.mock('@app/components/view-shell', () => ({},useViewShell: () => ({aside: { isCollapsed: () => true },- breakpoints: { narrow: () => false },+ breakpoints: { narrow: () => fixture.narrow },}),useViewControlHotkeys: () => {},SearchBar: () => null,}));vi.mock('@app/preferences/use-preference', () => ({- usePreference: () => createSignal(false),+ usePreference: () => {+ const [collapsed, setCollapsed] = createSignal(false);+ return [+ collapsed,+ (value: boolean) => {+ fixture.setCollapsed(value);+ setCollapsed(value);+ },+ ];+ },}));vi.mock('@core/mobile/isTouchDevice', () => ({isTouchDevice: () => fixture.touch,@@ -55,6 +66,22 @@ vi.mock('@ui', async () => ({Button: (props: JSX.ButtonHTMLAttributes<HTMLButtonElement> & { label?: string }) => <button aria-label={props.label} {...props} />,+ Dropdown: Object.assign(+ (+ props: ParentProps<{+ open: boolean;+ onOpenChange: (open: boolean) => void;+ }>+ ) => (+ <div>+ <button type="button" onClick={() => props.onOpenChange(true)}>+ Show CRM navigation+ </button>+ <Show when={props.open}>{props.children}</Show>+ </div>+ ),+ { Trigger: () => null, Content: (props: ParentProps) => props.children }+ ),}));vi.mock('@components/app/split-panel', () => ({SplitPanel: {@@ -118,8 +145,12 @@ vi.mock('../components/crm-sidebar', () => ({CrmSidebar: (props: {pipelines?: JSX.Element;onNavigate: (id: string) => void;+ onCollapse: () => void;}) => (<nav aria-label="CRM sidebar">+ <button type="button" onClick={props.onCollapse}>+ Collapse CRM sidebar+ </button><button type="button" onClick={() => props.onNavigate('active')}>Companies</button>@@ -226,7 +257,9 @@ afterEach(() => {fixture.pipelinesEnabled = true;fixture.listsEnabled = true;fixture.touch = true;+ fixture.narrow = false;fixture.openWithSplit.mockReset();+ fixture.setCollapsed.mockReset();});function setup(initialTab = 'active') {@@ -312,6 +345,19 @@ it('shows a pipeline another view asks for, in place of an open record', () => {expect(screen.queryByText('Sales record company:acme')).toBeNull();});+it('closes the narrow navigation menu on collapse without saving the preference', () => {+ fixture.touch = false;+ fixture.narrow = true;+ setup('pipeline:sales');+ const collapses = () =>+ screen.getAllByRole('button', { name: 'Collapse CRM sidebar' });+ fireEvent.click(screen.getByRole('button', { name: 'Show CRM navigation' }));+ expect(collapses()).toHaveLength(2);+ fireEvent.click(collapses()[1]!);+ expect(collapses()).toHaveLength(1);+ expect(fixture.setCollapsed).not.toHaveBeenCalled();+});+it('keeps the split close beside the collapsed sidebar toggle on a pipeline', () => {fixture.touch = false;setup('pipeline:sales');diff --git a/apps/web/src/features/crm/views/crm-workspace.tsx b/apps/web/src/features/crm/views/crm-workspace.tsxindex 4fa9499331..5e4055f91c 100644--- a/apps/web/src/features/crm/views/crm-workspace.tsx+++ b/apps/web/src/features/crm/views/crm-workspace.tsx@@ -60,7 +60,7 @@ import {function NavigationToggle(props: {onExpand: () => void;- children: import('solid-js').JSX.Element;+ children: (close: () => void) => JSX.Element;}) {const shell = useViewShell();const [open, setOpen] = createSignal(false);@@ -108,7 +108,7 @@ function NavigationToggle(props: {setOpen(false);}}>- {props.children}+ {props.children(() => setOpen(false))}</div></Dropdown.Content></Dropdown>@@ -368,7 +368,7 @@ export function CrmWorkspaceView(props: {onMount(() => {if (!listsEnabled() && active().startsWith('list:')) navigate('active');});- const sidebar = () => (+ const sidebar = (onCollapse: () => void = () => setCollapsed(true)) => (<CrmSidebarpipelines={<Show when={pipelinesEnabled()}>@@ -409,7 +409,7 @@ export function CrmWorkspaceView(props: {onImport={() => setImporting(true)}onExport={() => setExporting(true)}onSettings={view.host.openSettings}- onCollapse={() => setCollapsed(true)}+ onCollapse={onCollapse}/>);return (@@ -457,7 +457,7 @@ export function CrmWorkspaceView(props: {onOpenPipeline={selectPipeline}navigation={<NavigationToggle onExpand={() => setCollapsed(false)}>- <Suspense>{sidebar()}</Suspense>+ {(close) => <Suspense>{sidebar(close)}</Suspense>}</NavigationToggle>}/>@@ -487,7 +487,7 @@ export function CrmWorkspaceView(props: {navigation={<Show when={!isTouchDevice()}><NavigationToggle onExpand={() => setCollapsed(false)}>- <Suspense>{sidebar()}</Suspense>+ {(close) => <Suspense>{sidebar(close)}</Suspense>}</NavigationToggle></Show>}@@ -515,7 +515,7 @@ export function CrmWorkspaceView(props: {<Show when={!isTouchDevice()}><div class="flex h-12 shrink-0 items-center gap-3 px-4"><NavigationToggle onExpand={() => setCollapsed(false)}>- <Suspense>{sidebar()}</Suspense>+ {(close) => <Suspense>{sidebar(close)}</Suspense>}</NavigationToggle><h1class="flex h-7 min-w-0 flex-1 items-center px-1 text-sm font-semibold tracking-[-0.03em]"diff --git a/docs/agent-guide/crm.md b/docs/agent-guide/crm.mdindex ce8f7b6898..33c397dcce 100644--- a/docs/agent-guide/crm.md+++ b/docs/agent-guide/crm.md@@ -161,7 +161,8 @@ the entity actions menu and command menu with stage requests delayed; cancel theeditors without changing hosted data.`Collapse CRM sidebar` persists across visits; `Expand CRM sidebar` restores it.-At narrow widths, `Show CRM navigation` opens the same navigation in a menu.+At narrow widths, `Show CRM navigation` opens the same navigation in a menu;+`Collapse CRM sidebar` there closes the menu and leaves the saved preference alone.While the sidebar is collapsed, the split's **Close** sits before either toggle,including on a pipeline, and stays hidden when the split cannot close.The sidebar's Records and Lists sections can also collapse independently.