Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(calendar): keep event composer dropdowns open on click (#7510)

gbirman2f4160c098eb
diff --git a/apps/web/src/components/app/split-layout/components/PopoverSplitRenderer.tsx b/apps/web/src/components/app/split-layout/components/PopoverSplitRenderer.tsx
index b94b45949c..9651c4f4e7 100644
--- a/apps/web/src/components/app/split-layout/components/PopoverSplitRenderer.tsx
+++ b/apps/web/src/components/app/split-layout/components/PopoverSplitRenderer.tsx
@@ -1,7 +1,7 @@
import { SoupContextProvider } from '@app/features/next-soup/soup-context';
import { ContentLoading } from '@components/app/ContentLoading';
import { MobileDrawer } from '@components/app/mobile/MobileDrawer';
-import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';
+import { useHotkeyDOMScope } from '@core/hotkey/hotkeys';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { Dialog, Panel } from '@ui';
import { createMemo, createSignal, For, Show, Suspense } from 'solid-js';
@@ -139,16 +139,6 @@ function PopoverSplitModal(props: {
toolbarCollapser: { register: () => () => {} },
};
- registerHotkey({
- hotkey: 'escape',
- scopeId,
- description: 'Close Popover',
- keyDownHandler() {
- props.onClose();
- return true;
- },
- });
-
const attachPanel = (element: HTMLElement) => {
setPanelRef(element);
bindHotKeyDom(element);
diff --git a/apps/web/src/components/app/split-layout/tests/PopoverSplitRenderer.test.tsx b/apps/web/src/components/app/split-layout/tests/PopoverSplitRenderer.test.tsx
new file mode 100644
index 0000000000..e372fb6c29
--- /dev/null
+++ b/apps/web/src/components/app/split-layout/tests/PopoverSplitRenderer.test.tsx
@@ -0,0 +1,88 @@
+import { useHotKeyRoot } from '@core/hotkey/hotkeys';
+import { cleanup, render, screen } from '@solidjs/testing-library';
+import userEvent from '@testing-library/user-event';
+import { Select } from '@ui';
+import type { JSX } from 'solid-js';
+import { afterEach, expect, it, vi } from 'vitest';
+import { PopoverSplitRenderer } from '../components/PopoverSplitRenderer';
+import type { SplitContent, SplitMount } from '../layoutManager';
+
+vi.mock('@app/features/next-soup/soup-context', () => ({
+ SoupContextProvider: (props: { children: JSX.Element }) => props.children,
+}));
+
+vi.mock('@core/mobile/isTouchDevice', () => ({
+ isTouchDevice: () => false,
+}));
+
+afterEach(() => {
+ cleanup();
+ vi.unstubAllGlobals();
+});
+
+it('dismisses a nested select before closing its popover split on Escape', async () => {
+ vi.stubGlobal('scrollTo', vi.fn());
+ vi.stubGlobal(
+ 'ResizeObserver',
+ class {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+ }
+ );
+ const user = userEvent.setup();
+ const close = vi.fn();
+ const content: SplitContent = { type: 'component', id: 'test-composer' };
+ const mount: SplitMount = {
+ kind: 'component',
+ name: 'test-composer',
+ meta: {},
+ updateMeta: () => {},
+ element: () => (
+ <>
+ <input aria-label="Title" autofocus />
+ <Select options={['One', 'Two']} defaultValue="One">
+ <Select.Trigger aria-label="Choice">
+ <Select.Value />
+ </Select.Trigger>
+ <Select.Content
+ portalScope="local"
+ style={{ 'animation-name': 'none' }}
+ >
+ <Select.Listbox />
+ </Select.Content>
+ </Select>
+ </>
+ ),
+ };
+ render(() => {
+ useHotKeyRoot();
+ return (
+ <PopoverSplitRenderer
+ popovers={() =>
+ new Map([
+ [
+ 'composer',
+ {
+ id: 'composer',
+ content,
+ mount,
+ isOpen: true,
+ options: { content },
+ },
+ ],
+ ])
+ }
+ onClosePopover={close}
+ />
+ );
+ });
+ const trigger = screen.getByRole('button', { name: /Choice/ });
+ await user.click(trigger);
+ expect(trigger.getAttribute('aria-expanded')).toBe('true');
+ await user.keyboard('{Escape}');
+ expect(trigger.getAttribute('aria-expanded')).toBe('false');
+ expect(close).not.toHaveBeenCalled();
+ await user.keyboard('{Escape}');
+ expect(close).toHaveBeenCalledTimes(1);
+});
diff --git a/apps/web/src/features/block-calendar/components/EventComposerSplit.tsx b/apps/web/src/features/block-calendar/components/EventComposerSplit.tsx
index 3c3d7a1a98..632d7c5217 100644
--- a/apps/web/src/features/block-calendar/components/EventComposerSplit.tsx
+++ b/apps/web/src/features/block-calendar/components/EventComposerSplit.tsx
@@ -81,10 +81,7 @@ function EventComposerContent(
);
return (
- <div
- ref={attachHotkeys}
- class="portal-scope flex h-full min-h-0 flex-col p-4 text-ink"
- >
+ <div ref={attachHotkeys} class="flex h-full min-h-0 flex-col p-4 text-ink">
<EventForm
controller={controller}
macroCallsEnabled={macroCallsEnabled()}
diff --git a/apps/web/src/features/calendar/components/composer/EventComposerPopoverPortal.tsx b/apps/web/src/features/calendar/components/composer/EventComposerPopoverPortal.tsx
new file mode 100644
index 0000000000..1f138ab4e8
--- /dev/null
+++ b/apps/web/src/features/calendar/components/composer/EventComposerPopoverPortal.tsx
@@ -0,0 +1,16 @@
+import { Popover } from '@kobalte/core/popover';
+import { createSignal, type JSX } from 'solid-js';
+
+/** Keep nested menus inside their dialog or date/time popover's focus boundary. */
+export function EventComposerPopoverPortal(props: { children: JSX.Element }) {
+ const [searchRef, setSearchRef] = createSignal<HTMLDivElement>();
+ const mount = () =>
+ searchRef()?.closest<HTMLElement>('.portal-scope') ?? undefined;
+
+ return (
+ <>
+ <div class="hidden" ref={setSearchRef} />
+ <Popover.Portal mount={mount()}>{props.children}</Popover.Portal>
+ </>
+ );
+}
diff --git a/apps/web/src/features/calendar/components/composer/EventDateTimeInputs.tsx b/apps/web/src/features/calendar/components/composer/EventDateTimeInputs.tsx
index ca0c42d84c..9cb6c164cc 100644
--- a/apps/web/src/features/calendar/components/composer/EventDateTimeInputs.tsx
+++ b/apps/web/src/features/calendar/components/composer/EventDateTimeInputs.tsx
@@ -9,6 +9,7 @@ import { Layer } from '@ui/components/Layer';
import { cn } from '@ui/utils/classname';
import { createMemo, createSignal, Show } from 'solid-js';
import { formatLocalDate, parseLocalDate } from '../../utils/calendar-date';
+import { EventComposerPopoverPortal } from './EventComposerPopoverPortal';
import {
DAY_TIME_OPTIONS,
type EventTimeOption,
@@ -148,7 +149,7 @@ export function EventTimeInput(props: EventTimeInputProps) {
/>
</div>
- <Popover.Portal>
+ <EventComposerPopoverPortal>
<Layer depth={4}>
<Popover.Content
class="z-action-menu max-h-64 min-w-[var(--kb-popper-anchor-width)] overflow-y-auto rounded-xl border border-edge bg-menu-glass p-1.5 glass menu-open-animation"
@@ -189,7 +190,7 @@ export function EventTimeInput(props: EventTimeInputProps) {
/>
</Popover.Content>
</Layer>
- </Popover.Portal>
+ </EventComposerPopoverPortal>
</Popover>
);
}
diff --git a/apps/web/src/features/calendar/components/composer/EventDateTimeRangeFields.tsx b/apps/web/src/features/calendar/components/composer/EventDateTimeRangeFields.tsx
index 9fb5f91252..f5976d2719 100644
--- a/apps/web/src/features/calendar/components/composer/EventDateTimeRangeFields.tsx
+++ b/apps/web/src/features/calendar/components/composer/EventDateTimeRangeFields.tsx
@@ -8,6 +8,7 @@ import { ToggleSwitch } from '@ui/components/ToggleSwitch';
import { cn } from '@ui/utils/classname';
import { createSignal, createUniqueId } from 'solid-js';
import { formatLocalDate, parseLocalDate } from '../../utils/calendar-date';
+import { EventComposerPopoverPortal } from './EventComposerPopoverPortal';
import { dateLabelFormatter, EventTimeInput } from './EventDateTimeInputs';
import {
DAY_TIME_OPTIONS,
@@ -121,10 +122,10 @@ function EventDateTimeDropdown(props: EventDateTimeDropdownProps) {
/>
</Popover.Trigger>
- <Popover.Portal>
+ <EventComposerPopoverPortal>
<Layer depth={3}>
<Popover.Content
- class="portal-scope z-action-menu w-72 max-w-[calc(100vw-1rem)] overflow-hidden rounded-xl border border-edge bg-menu-glass glass menu-open-animation"
+ class="portal-scope z-action-menu w-72 max-w-[calc(100vw-1rem)] rounded-xl border border-edge bg-menu-glass glass menu-open-animation"
on:keydown={(event: KeyboardEvent) => {
if (event.key !== 'Escape') return;
event.preventDefault();
@@ -164,7 +165,7 @@ function EventDateTimeDropdown(props: EventDateTimeDropdownProps) {
</div>
</Popover.Content>
</Layer>
- </Popover.Portal>
+ </EventComposerPopoverPortal>
</Popover>
);
}
diff --git a/apps/web/src/features/calendar/components/composer/EventPropertyPills.test.tsx b/apps/web/src/features/calendar/components/composer/EventPropertyPills.test.tsx
index 3b9a6ba4ba..801ae00220 100644
--- a/apps/web/src/features/calendar/components/composer/EventPropertyPills.test.tsx
+++ b/apps/web/src/features/calendar/components/composer/EventPropertyPills.test.tsx
@@ -8,9 +8,11 @@ import userEvent from '@testing-library/user-event';
import { Dialog } from '@ui';
import { createSignal } from 'solid-js';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { EventDateTimeRangeFields } from './EventDateTimeRangeFields';
import {
EventComposerConferencePill,
EventComposerGuestsPill,
+ EventComposerLocationPill,
} from './EventPropertyPills';
import type {
EventEditorConferenceChoice,
@@ -72,12 +74,75 @@ class WebSocketStub {
}
beforeEach(() => {
+ Element.prototype.scrollIntoView = vi.fn();
vi.stubGlobal('ResizeObserver', ResizeObserverStub);
vi.stubGlobal('IntersectionObserver', ResizeObserverStub);
vi.stubGlobal('WebSocket', WebSocketStub);
vi.stubGlobal('scrollTo', vi.fn() as unknown as typeof window.scrollTo);
});
+describe('composer popovers inside a dialog', () => {
+ it('focuses the location input and preserves changes when reopened', async () => {
+ const user = userEvent.setup();
+ render(() => {
+ const [location, setLocation] = createSignal('');
+ return (
+ <Dialog open>
+ <input aria-label="Title" />
+ <EventComposerLocationPill
+ value={location()}
+ onChange={setLocation}
+ />
+ </Dialog>
+ );
+ });
+ screen.getByLabelText('Title').focus();
+ const trigger = screen.getByRole('button', { name: 'Location' });
+ await user.click(trigger);
+ const input = screen.getByRole('textbox', { name: 'Location' });
+ expect(document.activeElement).toBe(input);
+ await user.type(input, 'Meeting room');
+ await user.click(trigger);
+ expect(trigger.getAttribute('aria-expanded')).toBe('false');
+ await user.click(trigger);
+ expect(
+ (screen.getByRole('textbox', { name: 'Location' }) as HTMLInputElement)
+ .value
+ ).toBe('Meeting room');
+ });
+
+ it('selects a nested time without dismissing the date picker or composer', async () => {
+ const user = userEvent.setup();
+ render(() => {
+ const [start, setStart] = createSignal('2026-10-06T09:00');
+ return (
+ <Dialog open>
+ <input aria-label="Title" />
+ <EventDateTimeRangeFields
+ start={start()}
+ end="2026-10-06T10:00"
+ allDay={false}
+ onStartChange={setStart}
+ onEndChange={vi.fn()}
+ onAllDayChange={vi.fn()}
+ />
+ </Dialog>
+ );
+ });
+ screen.getByLabelText('Title').focus();
+ const trigger = screen.getByRole('button', {
+ name: 'Edit event start date and time',
+ });
+ await user.click(trigger);
+ const time = screen.getByLabelText('Start time');
+ await user.click(time);
+ await user.click(screen.getByRole('option', { name: '9:30 AM' }));
+ expect((time as HTMLInputElement).value).toBe('09:30');
+ expect(trigger.getAttribute('aria-expanded')).toBe('true');
+ expect(screen.getByLabelText('Title')).toBeTruthy();
+ });
+});
+
afterEach(() => {
cleanup();
vi.unstubAllGlobals();
@@ -123,24 +188,28 @@ describe('EventComposerConferencePill', () => {
expect(screen.queryByRole('option', { name: 'Macro call' })).toBeNull();
});
- it('shows the Macro selection and lets users switch to no link or Google Meet', async () => {
+ it('shows the Macro selection and lets users switch to no link or Google Meet inside the composer dialog', async () => {
const user = userEvent.setup();
render(() => {
const [choice, setChoice] =
createSignal<EventEditorConferenceChoice>('macro');
return (
- <EventComposerConferencePill
- value={choice()}
- macroCallsEnabled
- canKeepExisting={false}
- onChange={setChoice}
- />
+ <Dialog open>
+ <input aria-label="Title" />
+ <EventComposerConferencePill
+ value={choice()}
+ macroCallsEnabled
+ canKeepExisting={false}
+ onChange={setChoice}
+ />
+ </Dialog>
);
});
const trigger = screen.getByRole('button', {
name: /Video conferencing/,
});
expect(trigger.textContent).toContain('Macro call');
+ screen.getByLabelText('Title').focus();
await user.click(trigger);
await user.click(screen.getByRole('option', { name: 'No meeting link' }));
expect(trigger.textContent).toContain('Add meeting link');
diff --git a/apps/web/src/features/calendar/components/composer/EventPropertyPills.tsx b/apps/web/src/features/calendar/components/composer/EventPropertyPills.tsx
index f08ea8d644..8aeb9f24b4 100644
--- a/apps/web/src/features/calendar/components/composer/EventPropertyPills.tsx
+++ b/apps/web/src/features/calendar/components/composer/EventPropertyPills.tsx
@@ -27,6 +27,7 @@ import {
REMINDER_OVERRIDES_MAX,
REMINDER_PRESET_MINUTES,
} from '../../utils/event-reminders';
+import { EventComposerPopoverPortal } from './EventComposerPopoverPortal';
import {
type EventEditorCalendarOption,
type EventEditorConferenceChoice,
@@ -148,7 +149,7 @@ function ReadOnlyEventComposerGuestsPill(props: EventComposerGuestsPillProps) {
</span>
<CaretDownIcon class="size-3 shrink-0 text-ink-extra-muted" />
</Popover.Trigger>
- <Popover.Portal>
+ <EventComposerPopoverPortal>
<Layer depth={3}>
<Popover.Content class="z-action-menu w-72 max-w-[calc(100vw-1rem)] rounded-xl border border-edge bg-menu-glass p-1.5 text-sm glass menu-open-animation">
<Popover.Title class="sr-only">Event guests</Popover.Title>
@@ -187,7 +188,7 @@ function ReadOnlyEventComposerGuestsPill(props: EventComposerGuestsPillProps) {
</Show>
</Popover.Content>
</Layer>
- </Popover.Portal>
+ </EventComposerPopoverPortal>
</Popover>
);
}
@@ -255,7 +256,7 @@ function GuestsPopoverEditor(props: {
const ctx = useProperty();
return (
<Show when={ctx.editorOpen()}>
- <EditorPopover>
+ <EditorPopover portalScope="local">
<PropertyEntitySelector
config={{
isMultiSelect: true,
@@ -335,7 +336,7 @@ export function EventComposerLocationPill(
</span>
<CaretDownIcon class="size-3 shrink-0 text-ink-extra-muted" />
</Popover.Trigger>
- <Popover.Portal>
+ <EventComposerPopoverPortal>
<Layer depth={3}>
<Popover.Content
class="z-action-menu w-72 max-w-[calc(100vw-1rem)] rounded-xl border border-edge bg-menu-glass p-2 glass menu-open-animation"
@@ -357,7 +358,7 @@ export function EventComposerLocationPill(
/>
</Popover.Content>
</Layer>
- </Popover.Portal>
+ </EventComposerPopoverPortal>
</Popover>
);
}
@@ -439,7 +440,7 @@ export function EventComposerConferencePill(
</Select.Value>
<Select.Icon />
</Select.Trigger>
- <Select.Content>
+ <Select.Content portalScope="local">
<Select.Listbox />
</Select.Content>
</Select>
@@ -560,7 +561,7 @@ export function EventComposerRemindersPill(
</Select.Value>
<Select.Icon />
</Select.Trigger>
- <Select.Content class="w-56 p-0">
+ <Select.Content portalScope="local" class="w-56 p-0">
<div class="flex items-center justify-between border-edge-muted border-b px-3 py-2 text-xs text-ink-muted">
<span>Choose reminders</span>
<span
@@ -613,7 +614,7 @@ export function EventComposerRecurrencePill(
</Select.Value>
<Select.Icon />
</Select.Trigger>
- <Select.Content>
+ <Select.Content portalScope="local">
<Select.Listbox />
</Select.Content>
</Select>
@@ -656,7 +657,7 @@ export function EventComposerCalendarPill(
</Select.Value>
<Select.Icon />
</Select.Trigger>
- <Select.Content>
+ <Select.Content portalScope="local">
<Select.Listbox />
</Select.Content>
</Select>
@@ -722,7 +723,7 @@ export function EventComposerKindPill(props: EventComposerKindPillProps) {
</Select.Value>
<Select.Icon />
</Select.Trigger>
- <Select.Content>
+ <Select.Content portalScope="local">
<Select.Listbox />
</Select.Content>
</Select>
@@ -790,7 +791,7 @@ export function EventComposerDeclinePill(props: EventComposerDeclinePillProps) {
</Select.Value>
<Select.Icon />
</Select.Trigger>
- <Select.Content>
+ <Select.Content portalScope="local">
<Select.Listbox />
</Select.Content>
</Select>
@@ -836,7 +837,7 @@ export function EventComposerDeclineMessagePill(
</span>
<CaretDownIcon class="size-3 shrink-0 text-ink-extra-muted" />
</Popover.Trigger>
- <Popover.Portal>
+ <EventComposerPopoverPortal>
<Layer depth={3}>
<Popover.Content
class="z-action-menu w-72 max-w-[calc(100vw-1rem)] rounded-xl border border-edge bg-menu-glass p-2 glass menu-open-animation"
@@ -858,7 +859,7 @@ export function EventComposerDeclineMessagePill(
/>
</Popover.Content>
</Layer>
- </Popover.Portal>
+ </EventComposerPopoverPortal>
</Popover>
);
}
diff --git a/apps/web/src/features/calendar/components/composer/RecurrenceBuilder.tsx b/apps/web/src/features/calendar/components/composer/RecurrenceBuilder.tsx
index 6faf97ea42..45ace6e1ec 100644
--- a/apps/web/src/features/calendar/components/composer/RecurrenceBuilder.tsx
+++ b/apps/web/src/features/calendar/components/composer/RecurrenceBuilder.tsx
@@ -121,7 +121,7 @@ export function RecurrenceBuilder(props: RecurrenceBuilderProps) {
</Select.Value>
<Select.Icon />
</Select.Trigger>
- <Select.Content>
+ <Select.Content portalScope="local">
<Select.Listbox />
</Select.Content>
</Select>
diff --git a/apps/web/src/features/property/editors/popover/EditorPopover.tsx b/apps/web/src/features/property/editors/popover/EditorPopover.tsx
index db4a0eda4d..cd1e039706 100644
--- a/apps/web/src/features/property/editors/popover/EditorPopover.tsx
+++ b/apps/web/src/features/property/editors/popover/EditorPopover.tsx
@@ -6,6 +6,8 @@ import { PropertyRootContext } from '../../core/context';
type EditorPopoverProps = {
children: JSX.Element;
class?: string;
+ /** Mount inside the nearest portal scope when hosted in a modal. */
+ portalScope?: 'local';
/**
* Called on ESC or outside-interaction. Default: <Property.Root>'s closeEditor.
* Override to save-on-close, or to host the popover outside a Property.Root.
@@ -88,10 +90,10 @@ export function EditorPopover(props: EditorPopoverProps) {
};
return (
- // Keep the default body portal. The editor uses a virtual anchor rectangle,
- // so mounting inside a local portal-scope gives Floating UI the wrong
- // clipping and offset context.
+ // Virtual anchors normally use the body portal. Modal hosts opt into
+ // their own portal scope to keep focus and outside interactions local.
<Dropdown.Content
+ portalScope={props.portalScope}
class={cn(
'max-h-96 overflow-hidden flex flex-col w-full max-w-70 p-0 text-sm',
isInsideHoverCard && 'z-nested-action-menu!',
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index 50842dd305..327886deea 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -1051,6 +1051,11 @@ returning from an opened file.
Event composer dropdown triggers and date/time inputs use the theme control
surface, so they blend with the dialog instead of using the darker page fill.
+Their menus stay inside the composer's portal scope. Verify that calendar,
+recurrence, Guests, conferencing, Location, and Notifications open on the first
+click from the title field and accept changes without closing the composer.
+Open the start/end date picker and its nested time list; selecting a time keeps
+the date picker open. Escape dismisses the active menu before the composer.
The path selects the Month, Week, or Day period, and choosing another period updates
that path. Calendar navigation defaults to Day on phones and Week on desktop; the most