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(ios): recipient selector focus issue (#5026)
Peter Chinmanf21b9c29e58f
diff --git a/apps/web/src/features/block-email/component/BaseInput.tsx b/apps/web/src/features/block-email/component/BaseInput.tsxindex 2d1c6d1ac5..5fb5c97735 100644--- a/apps/web/src/features/block-email/component/BaseInput.tsx+++ b/apps/web/src/features/block-email/component/BaseInput.tsx@@ -1837,6 +1837,7 @@ export function BaseInput(props: {form().setRecipients('to', v))}triggerMode="input"+ portalScope={composePortalScope()}hideBordernoPaddingonChipDragStart={(option, e) =>@@ -1880,6 +1881,7 @@ export function BaseInput(props: {form().setRecipients('cc', v))}triggerMode="input"+ portalScope={composePortalScope()}hideBordernoPaddingonChipDragStart={(option, e) =>@@ -1909,6 +1911,7 @@ export function BaseInput(props: {form().setRecipients('bcc', v))}triggerMode="input"+ portalScope={composePortalScope()}hideBordernoPaddingonChipDragStart={(option, e) =>diff --git a/apps/web/src/features/block-email/component/MobileEmailComposeDrawer.tsx b/apps/web/src/features/block-email/component/MobileEmailComposeDrawer.tsxindex 99b8c820d4..d43589a41c 100644--- a/apps/web/src/features/block-email/component/MobileEmailComposeDrawer.tsx+++ b/apps/web/src/features/block-email/component/MobileEmailComposeDrawer.tsx@@ -44,6 +44,7 @@ export function MobileEmailComposeDrawer(props: {side="bottom"open={context.mobileReplyComposer.open()}onOpenChange={setDrawerOpen}+ closeOnOutsidePointerStrategy="pointerdown"preventScroll={false}preventScrollbarShift={false}breakPoints={[0.85]}diff --git a/apps/web/src/lib/core/component/RecipientSelector.tsx b/apps/web/src/lib/core/component/RecipientSelector.tsxindex 30a38636ef..774ab6fd7c 100644--- a/apps/web/src/lib/core/component/RecipientSelector.tsx+++ b/apps/web/src/lib/core/component/RecipientSelector.tsx@@ -303,8 +303,6 @@ export function RecipientSelector<K extends CombinedRecipientKind>(portalSearchRef()?.closest<HTMLElement>('.portal-scope') ?? undefined);};- const shouldRenderPortal = () =>- props.portalScope !== 'local' || portalMount() !== undefined;// The chips container caps its height and scrolls; keep the input's line// visible as chips push it down.@@ -571,6 +569,8 @@ export function RecipientSelector<K extends CombinedRecipientKind>(const selectedLen = () => props.selectedOptions.length;+ let contentEl: HTMLElement | undefined;+const onInputChange = (next: string) => {setInputValue(next);@@ -806,60 +806,106 @@ export function RecipientSelector<K extends CombinedRecipientKind>(</Combobox.Control><div class="hidden" ref={setPortalSearchRef} />- <Show when={shouldRenderPortal()}>- <Combobox.Portal mount={portalMount()}>- <Layer depth={2}>- <Combobox.Content class="z-modal-content bg-surface translate-y-1 border-edge p-2 rounded-xl shadow-lg shadow-drop-shadow ring ring-edge">- <Combobox.Listbox- ref={setListboxRef}- class="flex flex-col gap-1"- scrollToItem={scrollToItem()}- autoFocus="first"- >- {(items) => {- const arr = Array.from(items());- const count = arr.length;- const visibleCount = Math.min(- count,- RECIPIENT_OPTION_MAX_VISIBLE_COUNT- );- const height = visibleCount * RECIPIENT_OPTION_HEIGHT_PX;-- const [handle, setHandle] =- createSignal<VirtualizerHandle | null>(null);-- setScrollToItem(() => (key: string) => {- const virtualizerHandle = handle();- if (virtualizerHandle) {- const ndx = arr.findIndex((item) => item.key === key);- if (ndx > -1) {- virtualizerHandle.scrollToIndex(ndx, {- align: 'nearest',- });- }+ <Combobox.Portal mount={portalMount()}>+ <Layer depth={2}>+ <Combobox.Content+ ref={(el: HTMLElement) => {+ contentEl = el;+ }}+ // WebKit's tap handling moves focus to the tapped element's+ // nearest focusable ancestor and does not treat that as a+ // cancelable pointerdown default. With tabIndex={-1} the+ // dropdown itself is that ancestor, so the focus event stays+ // inside the dismissable layer instead of landing on e.g. a+ // mobile drawer's tabindex="-1" content; the focusin handler+ // below then hands focus straight back to the input so the+ // virtual keyboard stays open.+ tabIndex={-1}+ on:focusin={(e: FocusEvent) => {+ if (e.target === e.currentTarget) {+ inputRef()?.focus({ preventScroll: true });+ }+ }}+ // Keep focus on the combobox input while pressing options: the+ // browser's pointerdown default moves focus to the tapped+ // element's nearest focusable ancestor — inside a mobile drawer+ // that's corvu's tabindex="-1" content, which Kobalte's+ // dismissable layer treats as focus-outside and closes the+ // dropdown before a touch tap's `click` (where touch selection+ // happens) can fire. `click` is not a compatibility mouse event,+ // so it still fires with pointerdown's default canceled.+ // (Chromium honors this; WebKit needs the tabIndex above.)+ onPointerDown={(e: PointerEvent) => e.preventDefault()}+ // Never let a press inside the dropdown start a corvu drawer+ // drag (no-op outside drawers).+ data-corvu-no-drag=""+ onFocusOutside={(e) => {+ // Focus landing on an ANCESTOR of the dropdown (a container+ // like the mobile drawer's tabindex="-1" content receiving+ // tap-focus) is fallout from pressing an option, not the user+ // moving to another control — veto the dismissal and put+ // focus back on the input.+ const focused = e.detail.originalEvent.target;+ if (+ contentEl &&+ focused instanceof Node &&+ focused.contains(contentEl)+ ) {+ e.preventDefault();+ inputRef()?.focus({ preventScroll: true });+ }+ }}+ class="z-modal-content bg-surface translate-y-1 border-edge p-2 rounded-xl shadow-lg shadow-drop-shadow ring ring-edge"+ >+ <Combobox.Listbox+ ref={setListboxRef}+ class="flex flex-col gap-1"+ scrollToItem={scrollToItem()}+ autoFocus="first"+ >+ {(items) => {+ const arr = Array.from(items());+ const count = arr.length;+ const visibleCount = Math.min(+ count,+ RECIPIENT_OPTION_MAX_VISIBLE_COUNT+ );+ const height = visibleCount * RECIPIENT_OPTION_HEIGHT_PX;++ const [handle, setHandle] =+ createSignal<VirtualizerHandle | null>(null);++ setScrollToItem(() => (key: string) => {+ const virtualizerHandle = handle();+ if (virtualizerHandle) {+ const ndx = arr.findIndex((item) => item.key === key);+ if (ndx > -1) {+ virtualizerHandle.scrollToIndex(ndx, {+ align: 'nearest',+ });}- });-- return (- <VList- data={arr}- itemSize={RECIPIENT_OPTION_HEIGHT_PX}- style={{- height: `${height}px`,- }}- ref={setHandle}- >- {(item) => {- return <RecipientComboboxItem {...item} />;- }}- </VList>- );- }}- </Combobox.Listbox>- </Combobox.Content>- </Layer>- </Combobox.Portal>- </Show>+ }+ });++ return (+ <VList+ data={arr}+ itemSize={RECIPIENT_OPTION_HEIGHT_PX}+ style={{+ height: `${height}px`,+ }}+ ref={setHandle}+ >+ {(item) => {+ return <RecipientComboboxItem {...item} />;+ }}+ </VList>+ );+ }}+ </Combobox.Listbox>+ </Combobox.Content>+ </Layer>+ </Combobox.Portal><Combobox.ErrorMessage class="text-xs text-failure mt-1">*At least one participant is required</Combobox.ErrorMessage>