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(databases): select the last option on initial ArrowUp (#7579)
Wolf Mermelsteinf4606ae62411
diff --git a/apps/web/src/features/block-database/browser-test/table.browser.e2e.ts b/apps/web/src/features/block-database/browser-test/table.browser.e2e.tsindex a97f49571a..9eb43d245d 100644--- a/apps/web/src/features/block-database/browser-test/table.browser.e2e.ts+++ b/apps/web/src/features/block-database/browser-test/table.browser.e2e.ts@@ -135,3 +135,24 @@ test.describe('touch resizing', () => {await session.detach();});});++test('starts ArrowUp at the last select option and saves it with Enter', async ({+ page,+}) => {+ await page.getByRole('button', { name: 'Status: Open' }).click();+ const search = page.getByRole('combobox', { name: 'Search Status options' });+ await expect(search).toBeFocused();+ await search.press('ArrowUp');+ await expect(page.getByRole('option', { name: 'Done' })).toHaveAttribute(+ 'data-active',+ ''+ );+ await search.press('Enter');+ await expect(page.getByLabel('Writes', { exact: true })).toHaveText('1');+ await expect(page.getByRole('button', { name: 'Status: Open' })).toHaveCount(+ 0+ );+ await expect(page.getByRole('button', { name: 'Status: Done' })).toHaveCount(+ 2+ );+});diff --git a/apps/web/src/features/block-database/components/option-picker.test.tsx b/apps/web/src/features/block-database/components/option-picker.test.tsxindex 853ebea363..5ae50d1288 100644--- a/apps/web/src/features/block-database/components/option-picker.test.tsx+++ b/apps/web/src/features/block-database/components/option-picker.test.tsx@@ -11,6 +11,46 @@ afterEach(() => {});describe('option picker', () => {+ it.each([{ selected: [] }, { selected: ['To do'] }])(+ 'starts ArrowUp at the last option with selections $selected',+ async ({ selected }) => {+ const onPick = vi.fn();+ render(() => (+ <OptionPicker+ column={{+ id: 'status',+ name: 'Status',+ dataType: 'SELECT_STRING',+ isMultiSelect: false,+ options: [+ { id: 'to-do', label: 'To do', color: null },+ { id: 'doing', label: 'Doing', color: null },+ { id: 'done', label: 'Done', color: null },+ ],+ writable: true,+ }}+ selected={selected}+ search=""+ onSearch={vi.fn()}+ onPick={onPick}+ onClear={vi.fn()}+ onCreate={vi.fn()}+ />+ ));+ const search = screen.getByRole('combobox', {+ name: 'Search Status options',+ });+ search.focus();+ await userEvent.keyboard('{ArrowUp}');+ expect(search.getAttribute('aria-activedescendant')).toBe(+ screen.getByRole('option', { name: 'Done' }).id+ );+ expect(document.activeElement).toBe(search);+ await userEvent.keyboard('{Enter}');+ expect(onPick).toHaveBeenCalledExactlyOnceWith('Done');+ }+ );+it('filters options by the typed text, ignoring case', async () => {render(() => {const [search, setSearch] = createSignal('');diff --git a/apps/web/src/features/block-database/components/option-picker.tsx b/apps/web/src/features/block-database/components/option-picker.tsxindex c71f73000e..cab02868d0 100644--- a/apps/web/src/features/block-database/components/option-picker.tsx+++ b/apps/web/src/features/block-database/components/option-picker.tsx@@ -111,7 +111,13 @@ export function OptionPicker(props: {const move = (step: 1 | -1) => {const count = rows().length;if (!count) return;- setActive((current) => (current + step + count) % count);+ setActive((current) =>+ current < 0+ ? step === 1+ ? 0+ : count - 1+ : (current + step + count) % count+ );};return (<div class="flex w-56 flex-col">diff --git a/docs/AGENT_GUIDE/databases.md b/docs/AGENT_GUIDE/databases.mdindex 624d4fef1e..2d5129b521 100644--- a/docs/AGENT_GUIDE/databases.md+++ b/docs/AGENT_GUIDE/databases.md@@ -120,6 +120,8 @@ focused (**Search or create…**). Typing filters the options; when the typed nanot an option yet, a **Create “…”** row adds it, picks it, and keeps focus (on thecell for a single select, in the search for a multi-select, which stays open). Arrowkeys move through the rows and Enter picks; **Clear value** empties the cell.+From a freshly opened picker, Down starts at the first row and Up starts at the+last; both wrap around at the ends.Multi-select pickers toggle each option and keep the others.Each option row has a **⋯** button (`Edit <option>`) that opens the option editor: