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(tasks): keep Tab on an open project or task (#9355)
gbirmanf6e22d0fce92
diff --git a/apps/web/src/features/tasks-view/AGENTS.md b/apps/web/src/features/tasks-view/AGENTS.mdindex 7f19384ee6..013939caa5 100644--- a/apps/web/src/features/tasks-view/AGENTS.md+++ b/apps/web/src/features/tasks-view/AGENTS.md@@ -17,6 +17,7 @@ Main Tasks and reusable task-list hosts. Projects and CRM embed `TasksViewProvid- Group task lists by the Project property, matching the Project column and Board. The server labels project groups with the initiative name the viewer can read, and the cache's local grouping projection carries that label; a header resolves the name through the authorized project identity query only while its group is still labeled by its key. Projects sort by name with No Project last in every layout.- Keep project navigation in a separate Projects section above Saved views, with assigned-to-me, all-accessible, and created-by-me views; replace individual-project shortcuts and use one mobile Projects picker.- Preserve project scope through detail navigation, history, pagination, and editable-filter clearing; keep project views out of task queries and saved-task-view capture.+- Tab and Shift+Tab cycle sidebar tabs only over a list. Keep `TasksSidebar`'s key-time check for an open project or task: the sidebar remounts whenever the view crosses its layout breakpoint, so it registers after an open pane and eclipses any override the pane holds.- Save filters, relative due dates or valid calendar bounds, selected layout, grouping, and ordered sort directions; keep text search and scroll state local, and capture implicit person conditions as normal OR-valued facets.- Preserve stable tag/property bindings when labels disappear; skip unsupported or malformed conditions without discarding supported filters.diff --git a/apps/web/src/features/tasks-view/components/TasksSidebar.test.tsx b/apps/web/src/features/tasks-view/components/TasksSidebar.test.tsxnew file mode 100644index 0000000000..660ec566e8--- /dev/null+++ b/apps/web/src/features/tasks-view/components/TasksSidebar.test.tsx@@ -0,0 +1,143 @@+import { registerHotkey, useHotKeyRoot } from '@core/hotkey/hotkeys';+import { setActiveScope } from '@core/hotkey/state';+import { registerScope, removeScope } from '@core/hotkey/utils';+import { cleanup, render } from '@solidjs/testing-library';+import { createRoot, createSignal } from 'solid-js';+import { afterEach, beforeEach, expect, it, vi } from 'vitest';++const fixtures = vi.hoisted(() => ({+ scopeId: 'tasks-sidebar-test-scope',+ setTab: vi.fn(),+ projectId: (() => undefined) as () => string | undefined,+ selectedTask: (() => undefined) as () => { id: string } | undefined,+}));++vi.mock('@app/components/view-shell', async () => ({+ useViewTabHotkeys: (+ await import('@app/components/view-shell/use-view-tab-hotkeys')+ ).useViewTabHotkeys,+ ViewSidebar: { Root: () => null },+}));+vi.mock('@app/components/view-shell/SidebarCreateButton', () => ({+ SidebarCreateHeader: () => null,+}));+vi.mock('@app/features/connector-import/connector-import', () => ({+ ConnectorImportSidebar: () => null,+}));+vi.mock('@app/features/favorites/FavoriteContextMenu', () => ({+ FavoriteContextMenu: () => null,+}));+vi.mock('@app/features/favorites/FavoriteIcon', () => ({+ FavoriteIcon: () => null,+}));+vi.mock('@app/lib/split-router', async (importOriginal) => ({+ ...(await importOriginal<typeof import('@app/lib/split-router')>()),+ useParams: () => ({+ get projectId() {+ return fixtures.projectId();+ },+ }),+}));+vi.mock('@app/util/favorites', () => ({+ favoriteSplitContent: vi.fn(),+ useFavoriteDisplayName: vi.fn(),+}));+vi.mock('@components/app/split-layout/layout', () => ({+ useSplitLayout: () => ({}),+}));+vi.mock('@components/app/split-layout/layoutUtils', () => ({+ useSplitPanelOrThrow: () => ({+ splitHotkeyScope: fixtures.scopeId,+ isPanelActive: () => true,+ }),+}));+vi.mock('@queries/favorites/favorites', () => ({+ useFavoritesData: () => ({ data: [] }),+}));+vi.mock('../tasks-create-action', () => ({ TasksCreateAction: () => null }));+vi.mock('../tasks-view-context', () => ({+ useTasksView: () => ({+ state: { tab: 'my-tasks', search: '' },+ setState: vi.fn(),+ projectsEnabled: () => true,+ setTab: fixtures.setTab,+ selectedTask: () => fixtures.selectedTask(),+ isSidebarSectionOpen: () => true,+ setSidebarSectionOpen: vi.fn(),+ }),+}));+vi.mock('../views/task-saved-views', () => ({+ TaskSavedViewsList: () => null,+}));++import { TasksSidebar } from './TasksSidebar';++beforeEach(() => {+ registerScope({+ parentScopeId: 'global',+ scopeId: fixtures.scopeId,+ type: 'dom',+ });+ setActiveScope(fixtures.scopeId);+});++afterEach(() => {+ cleanup();+ vi.clearAllMocks();+ setActiveScope('global');+ removeScope(fixtures.scopeId);+});++const pressTab = (shiftKey = false) => {+ const keydown = new KeyboardEvent('keydown', {+ key: 'Tab',+ shiftKey,+ bubbles: true,+ cancelable: true,+ });+ document.dispatchEvent(keydown);+ document.dispatchEvent(+ new KeyboardEvent('keyup', { key: 'Tab', shiftKey, bubbles: true })+ );+ return keydown;+};++it('leaves Tab to focus order while a project or task is open, mounted after its override', () => {+ const [projectId, setProjectId] = createSignal<string>();+ const [selectedTask, setSelectedTask] = createSignal<{ id: string }>();+ fixtures.projectId = projectId;+ fixtures.selectedTask = selectedTask;++ // A pane's own override can't help: the sidebar remounts after it whenever+ // the view crosses the layout breakpoint, and the newest command wins.+ createRoot(() =>+ registerHotkey({+ hotkey: ['tab', 'shift+tab'],+ scopeId: fixtures.scopeId,+ description: 'Move focus within document',+ keyDownHandler: () => false,+ })+ );+ render(() => {+ useHotKeyRoot();+ return <TasksSidebar />;+ });++ expect(pressTab().defaultPrevented).toBe(true);+ expect(fixtures.setTab).toHaveBeenCalledExactlyOnceWith('team-tasks');+ fixtures.setTab.mockClear();++ setProjectId('launch');+ expect(pressTab().defaultPrevented).toBe(false);+ expect(pressTab(true).defaultPrevented).toBe(false);+ setProjectId(undefined);++ setSelectedTask({ id: 'launch-plan' });+ expect(pressTab().defaultPrevented).toBe(false);+ expect(pressTab(true).defaultPrevented).toBe(false);+ expect(fixtures.setTab).not.toHaveBeenCalled();+ setSelectedTask(undefined);++ expect(pressTab().defaultPrevented).toBe(true);+ expect(fixtures.setTab).toHaveBeenCalledExactlyOnceWith('team-tasks');+});diff --git a/apps/web/src/features/tasks-view/components/TasksSidebar.tsx b/apps/web/src/features/tasks-view/components/TasksSidebar.tsxindex 45416fec87..3f7ec01730 100644--- a/apps/web/src/features/tasks-view/components/TasksSidebar.tsx+++ b/apps/web/src/features/tasks-view/components/TasksSidebar.tsx@@ -9,6 +9,7 @@ import { ConnectorImportSidebar } from '@app/features/connector-import/connectorimport { FavoriteContextMenu } from '@app/features/favorites/FavoriteContextMenu';import { FavoriteIcon } from '@app/features/favorites/FavoriteIcon';import { t } from '@app/lib/i18n';+import { useParams } from '@app/lib/split-router';import {favoriteSplitContent,useFavoriteDisplayName,@@ -157,9 +158,11 @@ export function TasksSidebar() {setState,projectsEnabled,setTab,+ selectedTask,isSidebarSectionOpen,setSidebarSectionOpen,} = useTasksView();+ const params = useParams<{ projectId?: string }>();useViewTabHotkeys({scopeId: panel.splitHotkeyScope,@@ -170,6 +173,10 @@ export function TasksSidebar() {),activeId: () => state.tab,setActiveId: (id) => setTab(id as TasksTab),+ // Tab cycles these tabs over a list and is focus order over an open project+ // or task. A pane's own override can't hold this: the sidebar remounts after+ // it whenever the view crosses its layout breakpoint.+ shouldHandleSequentialKeyEvent: () => !params.projectId && !selectedTask(),});return (