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(forms): make the builder, preview and respond views usable on phones (#9012)
Wolf Mermelstein8b07352e41d0
diff --git a/apps/web/src/components/app/mobile/MobileCreateMenu.tsx b/apps/web/src/components/app/mobile/MobileCreateMenu.tsxindex 6bb6ac74a2..1899eb09ec 100644--- a/apps/web/src/components/app/mobile/MobileCreateMenu.tsx+++ b/apps/web/src/components/app/mobile/MobileCreateMenu.tsx@@ -25,7 +25,10 @@ export type MobileCreateMenuItem = {/** Floating create actions that unfold from the mobile New button. */export function MobileCreateMenu(props: {items: readonly MobileCreateMenuItem[];+ /** The trigger's text; New by default. */+ label?: string;}) {+ const label = () => props.label ?? t('mobile.new');const [open, setOpen] = createSignal(false);const [position, setPosition] = createSignal({right: 12,@@ -75,11 +78,11 @@ export function MobileCreateMenu(props: {<MobileDockIsland class="shrink-0"><Dialog.Triggerref={triggerRef}- aria-label={t('mobile.new')}+ aria-label={label()}class="relative flex h-(--mobile-chrome-button-size) items-center justify-center gap-1.5 rounded-full pl-3 pr-4 text-base font-medium whitespace-nowrap"><PlusIcon class="size-5.5 shrink-0" />- <span>{t('mobile.new')}</span>+ <span>{label()}</span></Dialog.Trigger></MobileDockIsland><Dialog.Portal>@@ -139,7 +142,7 @@ export function MobileCreateMenu(props: {class="flex h-(--mobile-chrome-button-size) items-center justify-center gap-1.5 rounded-full pl-3 pr-4 text-base font-medium outline-none focus-visible:ring-2 focus-visible:ring-accent"><PlusIcon class="mobile-create-menu-plus size-5.5 shrink-0" />- <span>{t('mobile.new')}</span>+ <span>{label()}</span></Dialog.CloseButton></MobileDockIsland></Dialog.Content>diff --git a/apps/web/src/features/block-form/components/builder/builder-chrome.test.tsx b/apps/web/src/features/block-form/components/builder/builder-chrome.test.tsxindex 1f30dc6ded..cf7017dbe2 100644--- a/apps/web/src/features/block-form/components/builder/builder-chrome.test.tsx+++ b/apps/web/src/features/block-form/components/builder/builder-chrome.test.tsx@@ -44,7 +44,7 @@ function mount() {descriptions,setName,setDescription,- nameField: screen.getByLabelText<HTMLInputElement>('Form name'),+ nameField: screen.getByLabelText<HTMLTextAreaElement>('Form name'),descriptionField:screen.getByLabelText<HTMLTextAreaElement>('Form description'),};@@ -71,7 +71,7 @@ describe('TitleCard', () => {onDescription={async () => true}/>));- const nameField = screen.getByLabelText<HTMLInputElement>('Form name');+ const nameField = screen.getByLabelText<HTMLTextAreaElement>('Form name');const descriptionField =screen.getByLabelText<HTMLTextAreaElement>('Form description');nameField.focus();diff --git a/apps/web/src/features/block-form/components/builder/builder-chrome.tsx b/apps/web/src/features/block-form/components/builder/builder-chrome.tsxindex eb4cf05568..c32e88edd5 100644--- a/apps/web/src/features/block-form/components/builder/builder-chrome.tsx+++ b/apps/web/src/features/block-form/components/builder/builder-chrome.tsx@@ -6,7 +6,7 @@ import { Button, cn } from '@ui';import { createSignal, For, type JSX, Show } from 'solid-js';import type { QuestionTypeId } from '../../core/question-types';import { QuestionTypeIcon } from '../question-type-icon';-import { DraftInput, DraftTextarea } from './draft-input';+import { DraftTextarea } from './draft-input';/** Holds the editor's layout while its shared document opens. */export function BuilderSkeleton() {@@ -78,11 +78,13 @@ export function TitleCard(props: {return (<section aria-label="Form details" class="flex min-w-0 flex-col"><div class="flex min-w-0 flex-col">- <DraftInput+ <DraftTextarea+ singleLinearia-label="Form name"value={props.name}maxlength={200}- class="h-8 w-full border-0 bg-transparent p-0 text-2xl font-semibold text-ink outline-none aria-invalid:text-failure"+ rows={1}+ class="w-full resize-none border-0 bg-transparent p-0 text-2xl leading-8 font-semibold text-ink outline-none field-sizing-content aria-invalid:text-failure"onCommit={props.onName}/><div class="mt-3 mb-6 flex flex-wrap items-center gap-2 text-sm">diff --git a/apps/web/src/features/block-form/components/builder/draft-input.test.tsx b/apps/web/src/features/block-form/components/builder/draft-input.test.tsxindex eaa376896d..4f5389d5c9 100644--- a/apps/web/src/features/block-form/components/builder/draft-input.test.tsx+++ b/apps/web/src/features/block-form/components/builder/draft-input.test.tsx@@ -2,7 +2,7 @@ import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';import { createSignal } from 'solid-js';import { afterEach, describe, expect, it } from 'vitest';import type { FormOption } from '../../core/form-model';-import { DraftInput } from './draft-input';+import { DraftInput, DraftTextarea } from './draft-input';import { OptionListEditor } from './option-list-editor';afterEach(cleanup);@@ -55,6 +55,32 @@ describe('DraftInput', () => {});});+describe('DraftTextarea', () => {+ it('commits a single-line name trimmed on Enter and refuses an empty one', () => {+ const committed: string[] = [];+ render(() => (+ <DraftTextarea+ singleLine+ aria-label="Form name"+ value="Untitled form"+ onCommit={(next) => {+ committed.push(next);+ }}+ />+ ));+ const field = screen.getByLabelText<HTMLTextAreaElement>('Form name');+ field.focus();+ fireEvent.input(field, { target: { value: ' Team survey ' } });+ fireEvent.keyDown(field, { key: 'Enter' });+ expect(committed).toEqual(['Team survey']);+ field.focus();+ fireEvent.input(field, { target: { value: ' ' } });+ field.blur();+ expect(committed).toEqual(['Team survey']);+ expect(field.value).toBe('Untitled form');+ });+});+describe('OptionListEditor', () => {it('keeps an option row and its draft mounted when a read replaces the options', () => {const [options, setOptions] = createSignal<readonly FormOption[]>([diff --git a/apps/web/src/features/block-form/components/builder/draft-input.tsx b/apps/web/src/features/block-form/components/builder/draft-input.tsxindex 85b77faf96..08cdefc4aa 100644--- a/apps/web/src/features/block-form/components/builder/draft-input.tsx+++ b/apps/web/src/features/block-form/components/builder/draft-input.tsx@@ -163,7 +163,9 @@ export function DraftInput(/*** The textarea form of `DraftInput`, for prose: the draft is committed as- * typed (an empty one too) and Enter starts a new line.+ * typed (an empty one too) and Enter starts a new line. `singleLine` keeps+ * `DraftInput`'s rules (trimmed, never empty, Enter commits) for a name that+ * wraps instead of scrolling sideways.*/export function DraftTextarea(props: Omit<@@ -172,13 +174,14 @@ export function DraftTextarea(> & {value: string;onCommit: Commit;+ singleLine?: boolean;}) {- const [local, rest] = splitProps(props, ['value', 'onCommit']);+ const [local, rest] = splitProps(props, ['value', 'onCommit', 'singleLine']);const draft = createDraft({value: () => local.value,- trim: false,- allowEmpty: true,+ trim: !!local.singleLine,+ allowEmpty: !local.singleLine,onCommit: (value) => local.onCommit(value),});return (@@ -186,7 +189,7 @@ export function DraftTextarea({...rest}ref={draft.ref}aria-invalid={draft.refused()}- onKeyDown={(event) => draft.onKeyDown(event, false)}+ onKeyDown={(event) => draft.onKeyDown(event, !!local.singleLine)}onBlur={draft.onBlur}/>);diff --git a/apps/web/src/features/block-form/form-block.tsx b/apps/web/src/features/block-form/form-block.tsxindex 5b69b43c03..0094d78da5 100644--- a/apps/web/src/features/block-form/form-block.tsx+++ b/apps/web/src/features/block-form/form-block.tsx@@ -229,7 +229,8 @@ function FormBlockContent(props: {when={props.respondOnly}fallback={<FormPageView- header={FormHeader}+ // The touch header has no room for tabs beside the actions.+ header={isTouchDevice() ? undefined : FormHeader}source={source}tab={tab()}respondLink={link()}diff --git a/apps/web/src/features/block-form/form-respond-page.tsx b/apps/web/src/features/block-form/form-respond-page.tsxindex dd60caa1da..292d0996b5 100644--- a/apps/web/src/features/block-form/form-respond-page.tsx+++ b/apps/web/src/features/block-form/form-respond-page.tsx@@ -49,7 +49,7 @@ function FormRespondContent(props: { formId: string }) {return (<FormProvider value={context}><Layer depth={1}>- <main class="h-full min-h-0 overflow-y-auto bg-canvas-base text-ink">+ <main class="h-full min-h-0 overflow-y-auto bg-canvas-base text-ink touch:pt-(--safe-top) touch:pb-(--mobile-content-inset-bottom)"><Showwhen={source.detail()}fallback={diff --git a/apps/web/src/features/block-form/views/builder-view.tsx b/apps/web/src/features/block-form/views/builder-view.tsxindex e2a2ec5cac..0e7391a9f2 100644--- a/apps/web/src/features/block-form/views/builder-view.tsx+++ b/apps/web/src/features/block-form/views/builder-view.tsx@@ -1,4 +1,11 @@import { DocumentOutline } from '@app/components/DocumentOutline';+import { FloatRegion } from '@components/app/mobile/float-regions/FloatRegion';+import {+ MobileCreateMenu,+ type MobileCreateMenuItem,+} from '@components/app/mobile/MobileCreateMenu';+import { isTouchDevice } from '@core/mobile/isTouchDevice';+import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';import { fireAndForget } from '@core/util/fireAndForget';import ArrowSquareOut from '@icon/system/regular/arrow-square-out.svg';import CalendarCheck from '@icon/system/regular/calendar-check.svg';@@ -528,6 +535,37 @@ function BuilderCanvas(/>);+ const addBooking = () => {+ const existing = booking();+ if (existing) revealBooking(existing.id);+ else setChoosingBooking(true);+ };+ // Touch floats these above the dock, in place of the page's New.+ const addActions = (): MobileCreateMenuItem[] => [+ {+ label: 'Section',+ icon: Plus,+ disabled: props.detail.tableGone,+ onSelect: () => addSectionAndFocus('questions'),+ },+ {+ label: 'Gate',+ icon: ShieldCheck,+ disabled: props.detail.tableGone,+ onSelect: () => addSectionAndFocus('gate'),+ },+ ...(booking() || context.booking.available()+ ? [+ {+ label: booking() ? 'View meeting link' : 'Meeting link',+ icon: CalendarCheck,+ disabled: props.detail.tableGone,+ onSelect: addBooking,+ },+ ]+ : []),+ ];+const hiddenColumnRows = () =>builder.hiddenColumns().map((hidden) => ({id: hidden.id,@@ -1019,52 +1057,68 @@ function BuilderCanvas(columns={hiddenColumnRows()}onAdd={(columnId) => builder.addExistingColumn(columnId)}/>- <div- class="mt-6 flex flex-wrap gap-3"- role="group"- aria-label="Add to form"+ <Show+ when={!isTouchDevice()}+ fallback={+ <FloatRegion+ region="accessory"+ active={() =>+ (props.active ?? true) && !virtualKeyboardVisible()+ }+ >+ <div class="flex justify-end px-(--mobile-chrome-gutter)">+ <MobileCreateMenu label="Add" items={addActions()} />+ </div>+ </FloatRegion>+ }>- <Button- variant="secondary"- size="md"- class="h-14 flex-1 justify-start gap-2 rounded-xl px-5"- disabled={props.detail.tableGone}- onClick={() => addSectionAndFocus('questions')}- >- <Plus class="size-4" />- Add section- </Button>- <Button- variant="secondary"- size="md"- class="h-14 flex-1 justify-start gap-2 rounded-xl px-5"- disabled={props.detail.tableGone}- onClick={() => addSectionAndFocus('gate')}+ <div+ class="mt-6 flex flex-wrap gap-3"+ role="group"+ aria-label="Add to form">- <ShieldCheck class="size-4" />- Add gate- </Button>- <Show when={booking() || context.booking.available()}><Buttonvariant="secondary"size="md"- class="h-14 flex-1 justify-start gap-2 rounded-xl px-5"+ class="h-14 min-w-max flex-1 justify-start gap-2 rounded-xl px-5"disabled={props.detail.tableGone}- onClick={(event) => {- const existing = booking();- if (existing) {- revealBooking(existing.id);- } else {- dialogReturnFocus = event.currentTarget;- setChoosingBooking(true);- }- }}+ onClick={() => addSectionAndFocus('questions')}>- <CalendarCheck class="size-4" />- {booking() ? 'View meeting link' : 'Add meeting link'}+ <Plus class="size-4" />+ Add section</Button>- </Show>- </div>+ <Button+ variant="secondary"+ size="md"+ class="h-14 min-w-max flex-1 justify-start gap-2 rounded-xl px-5"+ disabled={props.detail.tableGone}+ onClick={() => addSectionAndFocus('gate')}+ >+ <ShieldCheck class="size-4" />+ Add gate+ </Button>+ <Show when={booking() || context.booking.available()}>+ <Button+ variant="secondary"+ size="md"+ class="h-14 min-w-max flex-1 justify-start gap-2 rounded-xl px-5"+ disabled={props.detail.tableGone}+ onClick={(event) => {+ const existing = booking();+ if (existing) {+ revealBooking(existing.id);+ } else {+ dialogReturnFocus = event.currentTarget;+ setChoosingBooking(true);+ }+ }}+ >+ <CalendarCheck class="size-4" />+ {booking() ? 'View meeting link' : 'Add meeting link'}+ </Button>+ </Show>+ </div>+ </Show></div></div><div class="pointer-events-none absolute inset-y-0 left-4 z-1 hidden w-10 @min-[880px]/builder:block">diff --git a/docs/agent-guide/forms.md b/docs/agent-guide/forms.mdindex 5148c2ed1d..4506015920 100644--- a/docs/agent-guide/forms.md+++ b/docs/agent-guide/forms.md@@ -35,7 +35,8 @@ decides who may respond.Editors see **Build**, **Responses** (with its count), and **Settings** in theshared pill tab selector beside the form title in the top bar, kept per split (a split opened with-`params.view` `responses` or `share` starts there). Viewers (respondents) land on the respond page+`params.view` `responses` or `share` starts there). On touch devices the tabs sit at the top+of the page, below the floating header. Viewers (respondents) land on the respond pageinstead. The header's primary button, for owners, is **Publish** (opens sharing)until someone responds or the form is shared (public, a channel, the team),then **Open form** (respond view in a new split); other editors always see@@ -54,7 +55,8 @@ question or existing database field to that section, regardless of the currentselection. Three visible actions sit below the canvas: **Add section** adds aquestion section directly, **Add gate** adds a gate with its inline rule editoropen, and **Add meeting link** opens the booking-link picker (when scheduling is-available). Hover a question boundary to reveal a plus that inserts a question+available). On touch devices these three float above the dock as an **Add**+menu (Section, Gate, Meeting link) in place of New. Hover a question boundary to reveal a plus that inserts a questionat that position. Hover between sections to insert a **Section** or **Gate**.These controls also appear on keyboard focus and stay visible while their menusare open. Meeting links can only be added at the end; adding other sections later