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(mobile): let a tap inside a stacked sheet press its controls (#8839)
gbirman8181dd407374
diff --git a/.agents/rules/web/mobile.md b/.agents/rules/web/mobile.mdindex c6cc8eba4e..2890b33718 100644--- a/.agents/rules/web/mobile.md+++ b/.agents/rules/web/mobile.md@@ -53,8 +53,10 @@ read their code, and follow that pattern rather than inventing a new one.place with a back row.- A backdrop tap only dismisses: `MobileDrawer` swallows the rest of that tap,so it never presses what the scrim covered, even when the sheet unmounts as- it closes (a `<Show>` around it, or `openDialog`). Don't add per-sheet- delays or click guards for it.+ it closes (a `<Show>` around it, or `openDialog`). It swallows only a tap+ that really closed the sheet, so an owner that keeps its sheet open while+ another is stacked on it leaves that sheet's controls pressable. Don't add+ per-sheet delays or click guards for it.- A sheet opened from another sheet stacks on it under its own scrim, whichshares the sheets' layer (as Dialog's does), so the sheet beneath dims withthe page and only the top sheet's handle stands out. Open it under thediff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex ce2c0912d2..e36fc0bfd1 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -27,7 +27,8 @@ Discussion link scrolling has a backend-free browser regression:Phone sheets stacked on each other (Connect email over Settings, Add guests,RSVP scope and the delete confirmation over event details) have a backend-free-browser regression for backdrop taps that must not press what the scrim covers:+browser regression for backdrop taps that must not press what the scrim covers,+and for taps inside the top sheet that must still press its own controls:`bunx playwright test --config src/components/app/mobile/browser-test/playwright.config.ts`.Composer typeahead menus choosing the side with room for their full listdiff --git a/apps/web/src/components/app/mobile/MobileDrawer.tsx b/apps/web/src/components/app/mobile/MobileDrawer.tsxindex 052086c2f1..c592972a5d 100644--- a/apps/web/src/components/app/mobile/MobileDrawer.tsx+++ b/apps/web/src/components/app/mobile/MobileDrawer.tsx@@ -249,7 +249,8 @@ function dismissesDrawer(event: PointerEvent) {* its owner unmounts on close (a `<Show>` around it, or `openDialog`'s host)* takes the scrim with it, so the tap's mouse events and click are hit-tested* against the control underneath and press it. Swallow them until the tap's- * click, the next pointerdown or a key press.+ * click, the next pointerdown or a key press, but only once the drawer has+ * really closed: an owner that keeps it open leaves the tap to its target.*/function swallowRestOfTap() {const listening = new AbortController();@@ -276,7 +277,16 @@ function swallowRestOfTap() {*/export const MobileDrawer = Object.assign((props: ComponentProps<typeof Drawer>) => {- const [local, rest] = splitProps(props, ['onOutsidePointer']);+ const [local, rest] = splitProps(props, [+ 'onOutsidePointer',+ 'onOpenChange',+ ]);+ let uncontrolledOpen = props.initialOpen ?? false;+ let disposed = false;+ onCleanup(() => {+ disposed = true;+ });+ const closed = () => disposed || !(props.open ?? uncontrolledOpen);return (<DrawerbreakPoints={[0.8]}@@ -284,10 +294,22 @@ export const MobileDrawer = Object.assign(noOutsidePointerEvents={false}restoreFocus={false}{...rest}+ onOpenChange={(open) => {+ uncontrolledOpen = open;+ local.onOpenChange?.(open);+ }}onOutsidePointer={(event) => {if (!dismissesDrawer(event)) event.preventDefault();local.onOutsidePointer?.(event);- if (!event.defaultPrevented) swallowRestOfTap();+ if (event.defaultPrevented) return;+ // Corvu asks to close next, but the owner may keep the drawer open:+ // a sheet stacked from another dismiss stack (an imperative+ // dialog's host) is outside it, and the tap belongs to that sheet.+ // The microtask runs after the close request and before the tap's+ // mouse events.+ queueMicrotask(() => {+ if (closed()) swallowRestOfTap();+ });}}/>);diff --git a/apps/web/src/components/app/mobile/browser-test/fixture.tsx b/apps/web/src/components/app/mobile/browser-test/fixture.tsxindex c2f8335774..830359dc11 100644--- a/apps/web/src/components/app/mobile/browser-test/fixture.tsx+++ b/apps/web/src/components/app/mobile/browser-test/fixture.tsx@@ -33,7 +33,13 @@ function EmailSettingsPage() {const connectEmail = () => {const handle = openDialog(EmailProviderDialog,- { outlookAvailable: true, onSelect: () => handle.close() },+ {+ outlookAvailable: true,+ onSelect: (provider) => {+ press(`Connect ${provider}`);+ handle.close();+ },+ },{ owner });};@@ -118,7 +124,9 @@ function EventDetailsDrawer(props: { onClose: () => void }) {<Dialog.Title class="px-4 pb-2 text-base font-semibold">Add guests</Dialog.Title>- <div class="h-40 px-4">Guest picker</div>+ <div class="h-40 px-4">+ <Button onClick={() => press('Add guest')}>Add Priya</Button>+ </div></Dialog><MobileDrawerside="bottom"@@ -129,7 +137,11 @@ function EventDetailsDrawer(props: { onClose: () => void }) {<MobileDrawer.Overlay /><MobileDrawer.Content aria-label="RSVP to recurring event"><MobileDrawer.Handle />- <div class="h-40 px-6">This event or all events</div>+ <div class="h-40 px-6">+ <Button onClick={() => press('All events')}>+ All events+ </Button>+ </div></MobileDrawer.Content></MobileDrawer.Portal></MobileDrawer>diff --git a/apps/web/src/components/app/mobile/browser-test/stacked-sheets.browser.e2e.ts b/apps/web/src/components/app/mobile/browser-test/stacked-sheets.browser.e2e.tsindex 22a9de8859..4dd431909a 100644--- a/apps/web/src/components/app/mobile/browser-test/stacked-sheets.browser.e2e.ts+++ b/apps/web/src/components/app/mobile/browser-test/stacked-sheets.browser.e2e.ts@@ -70,6 +70,45 @@ for (const [opener, sheetName] of [});}+for (const [opener, sheetName, control, result] of [+ ['Add guests', 'Add guests', 'Add Priya', 'Add guest'],+ ['RSVP', 'RSVP to recurring event', 'All events', 'All events'],+ ['Delete', 'Delete event', 'Delete', 'Confirm delete'],+]) {+ test(`a tap on ${control} in ${sheetName} over event details presses it`, async ({+ page,+ }) => {+ await page.goto('/?scenario=event');+ const details = page.getByRole('dialog', { name: 'Weekly product sync' });+ await settled(details);+ await tap(page, details.getByRole('button', { name: opener }));+ const sheet = page.getByRole('dialog', { name: sheetName });+ await settled(sheet);++ await tap(page, sheet.getByRole('button', { name: control, exact: true }));++ await expect(pressed(page)).toHaveText(result);+ await expect(details).toBeVisible();+ });+}++test('a tap on Gmail in Connect email over Settings presses it', async ({+ page,+}) => {+ await page.goto('/?scenario=settings');+ const settings = page.getByRole('dialog', { name: 'Settings' });+ await settled(settings);+ await tap(page, page.getByRole('button', { name: 'Add account' }));+ const connectEmail = page.getByRole('dialog', { name: 'Connect email' });+ await settled(connectEmail);++ await tap(page, connectEmail.getByRole('button', { name: 'Gmail' }));++ await expect(pressed(page)).toHaveText('Connect GMAIL');+ await expect(connectEmail).toHaveCount(0);+ await expect(settings).toBeVisible();+});+test('a tap on the backdrop of event details closes it without pressing the page', async ({page,}) => {