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(email/mobile): fix layering, height and focus issues for mobile email drawer (#4668)
Seamus55296aa3ab25
diff --git a/js/app/packages/app/component/mobile/MobileDrawer.tsx b/js/app/packages/app/component/mobile/MobileDrawer.tsxindex 57e16cdbf8..db63045bd7 100644--- a/js/app/packages/app/component/mobile/MobileDrawer.tsx+++ b/js/app/packages/app/component/mobile/MobileDrawer.tsx@@ -47,8 +47,23 @@ export function scrollToFocusedInput(e: FocusEvent, offset = 40) {** Also handles default styling, which can be overridden via the `class` prop.*/-function MobileDrawerContent(props: ComponentProps<typeof Drawer.Content>) {- const [local, rest] = splitProps(props, ['class']);+function MobileDrawerContent(+ props: ComponentProps<typeof Drawer.Content> & {+ /** Maximum height as a percentage of the viewport (vh). Clamped to 100. Defaults to 80. */+ maxHeight?: number;+ /** Initial/start height as a percentage of the viewport (vh). Clamped to 100. Fits content when omitted. */+ targetHeight?: number;+ }+) {+ const [local, rest] = splitProps(props, [+ 'class',+ 'maxHeight',+ 'targetHeight',+ ]);++ const maxHeight = () => Math.min(100, local.maxHeight ?? 80);+ const targetHeight = () =>+ local.targetHeight != null ? Math.min(100, local.targetHeight) : undefined;onCleanup(() => {clearTimeout(scrollTimer);@@ -61,11 +76,18 @@ function MobileDrawerContent(props: ComponentProps<typeof Drawer.Content>) {onFocusIn={(e: FocusEvent) => {scrollToFocusedInput(e);}}+ style={{+ '--drawer-max-h': `${maxHeight()}vh`,+ ...(targetHeight() != null+ ? { '--drawer-h': `${targetHeight()}vh` }+ : {}),+ }}class={cn('portal-scope',- 'bottom-(--virtual-keyboard-height,0) fixed inset-x-0 z-modal bg-surface rounded-t-2xl flex flex-col max-h-[80vh] data-transitioning:transition-transform data-transitioning:duration-200 ease-out',+ 'bottom-(--virtual-keyboard-height,0) fixed inset-x-0 z-modal bg-surface rounded-t-2xl flex flex-col max-h-(--drawer-max-h) data-transitioning:transition-transform data-transitioning:duration-200 ease-out',+ targetHeight() != null ? 'h-(--drawer-h)' : 'h-fit',virtualKeyboardVisible()- ? 'pb-0 max-h-[calc(80vh-var(--virtual-keyboard-height))] overflow-y-auto'+ ? 'pb-0 max-h-[calc(var(--drawer-max-h)-var(--virtual-keyboard-height))] overflow-y-auto': 'pb-(--safe-bottom)',local.class)}diff --git a/js/app/packages/block-email/component/BaseInput.tsx b/js/app/packages/block-email/component/BaseInput.tsxindex 75553a5e19..b85bda788c 100644--- a/js/app/packages/block-email/component/BaseInput.tsx+++ b/js/app/packages/block-email/component/BaseInput.tsx@@ -54,7 +54,7 @@ import Reply from '@phosphor/arrow-bend-up-left.svg';import Forward from '@phosphor/arrow-bend-up-right.svg';import ChevronDown from '@phosphor/caret-down.svg';-import ClockIcon from '@phosphor/clock.svg';+import CaretRight from '@phosphor/caret-right.svg';import DotsThree from '@phosphor/dots-three.svg';import Paperclip from '@phosphor/paperclip.svg';import PencilSimple from '@phosphor/pencil-simple.svg';@@ -62,7 +62,6 @@ import Quotes from '@phosphor/quotes.svg';import TextAa from '@phosphor/text-aa.svg';import Trash from '@phosphor/trash.svg';-import XIcon from '@phosphor/x.svg';import ArrowCounterClockwise from '@phosphor-icons/core/regular/arrow-counter-clockwise.svg?component-solid';import { queryClient } from '@queries/client';import {@@ -99,6 +98,7 @@ import {cn,Dropdown,HoverCard,+ Layer,SendButton,Surface,Tooltip,@@ -1555,6 +1555,7 @@ export function BaseInput(props: {const hasBodyText = () => bodyMacro().trim().length > 0;const isMobileDrawer = () => props.mobileDrawer !== undefined;+ const composePortalScope = () => (isMobileDrawer() ? 'local' : undefined);const sendActionHidden = () =>isMobile() &&!hasBodyText() &&@@ -1573,9 +1574,19 @@ export function BaseInput(props: {const footerSignatureHtml = () =>isMobileDrawer() ? undefined : replySignatureHtml();const mobileRecipientSelectorClass =- 'min-w-0 flex-1 bg-transparent rounded-none! [&_input]:ml-0! [&_input]:basis-full! [&_input]:w-full! [&_input]:min-w-28! [&_input]:text-[17px] [&_input]:leading-6 [&_input]:text-ink [&_input]:placeholder:text-ink-placeholder';+ 'min-w-0 flex-1 bg-transparent rounded-none! [&_input]:ml-0! [&_input]:min-w-0! [&_input]:text-[17px] [&_input]:leading-6 [&_input]:text-ink [&_input]:placeholder:text-ink-placeholder';const mobileDrawerRowClass ='w-full gap-2 min-h-16 border-b border-edge-muted/70 focus-within:border-accent';+ const mobileDrawerCcBccOpen = () =>+ !!showCc() ||+ !!showBcc() ||+ form().recipients().cc.length > 0 ||+ form().recipients().bcc.length > 0;+ const toggleMobileDrawerCcBcc = () => {+ const next = !mobileDrawerCcBccOpen();+ setShowCc(next);+ setShowBcc(next);+ };const toggleQuotedText = () => {const replyingTo = props.replyingTo();@@ -1679,70 +1690,11 @@ export function BaseInput(props: {</Dropdown>);- const MobileOverflowMenu = () => (- <Dropdown>- <Dropdown.Trigger- as={Button}- variant="ghost"- size="icon-sm"- class="rounded-full border border-edge-muted/70 bg-transparent"- tooltip="More"- >- <DotsThree class="size-4" />- </Dropdown.Trigger>- <Dropdown.Content portalScope="local" class="min-w-44">- <Dropdown.Group>- <Show when={ENABLE_EMAIL_SCHEDULED_SEND && !sendActionHidden()}>- <EmailDateSelector- sendTime={form().sendTime() ?? null}- onSendTimeChange={handleSendTimeChange}- disabled={scheduleSendDisabled()}- disablePortal={isMobile()}- trigger={(state) => (- <div- aria-disabled={scheduleSendDisabled()}- class={cn(- 'group rounded-lg w-full min-w-44 flex items-center gap-1.5 p-1.5 px-2 text-left font-normal text-sm cursor-default outline-none hover:bg-ink/5 group-data-[expanded]/date-selector-trigger:bg-ink/5',- scheduleSendDisabled() &&- 'opacity-50 cursor-not-allowed hover:bg-transparent'- )}- >- <ClockIcon- class={cn(- 'size-4 shrink-0',- state.selectedDate && 'text-accent'- )}- />- <span class="flex-1 truncate">Schedule send</span>- <Show when={state.formattedDate}>- {(date) => (- <span class="max-w-20 truncate text-xs text-ink-extra-muted">- {date()}- </span>- )}- </Show>- </div>- )}- />- </Show>- <Dropdown.Item- onSelect={() => setShowFormatRibbon(!showFormatRibbon())}- >- <TextAa class="size-4 shrink-0" />- <span class="flex-1 truncate">- {showFormatRibbon() ? 'Hide formatting' : 'Show formatting'}- </span>- </Dropdown.Item>- </Dropdown.Group>- </Dropdown.Content>- </Dropdown>- );-return (<Surfaceclass={cn('relative flex flex-col flex-1 max-w-full min-h-0',- isMobileDrawer() && 'h-full',+ isMobileDrawer() && 'min-h-full overflow-y-scroll overscroll-y-none',props.unframed ? 'rounded-none' : 'rounded-xl')}style={props.unframed ? { 'background-color': 'transparent' } : undefined}@@ -1760,35 +1712,36 @@ export function BaseInput(props: {depth={2}solid>- <Show when={props.mobileDrawer}>- <div- data-corvu-no-drag=""- class="shrink-0 h-12 px-3 flex items-center justify-between"- >- <div class="flex items-center gap-1 min-w-0">- <Button- variant="ghost"- size="icon-sm"- class="rounded-full border border-edge-muted/70 bg-transparent"- tooltip={savedDraftId() ? 'Delete draft' : 'Discard draft'}- onClick={deleteDraftAndReset}- >- <XIcon class="size-4" />- </Button>- </div>- <div class="ml-auto flex items-center gap-1">- <AttachButton- variant="ghost"- class="rounded-full border border-edge-muted/70 bg-transparent"- />- <MobileOverflowMenu />- <SendButton- disabled={sendActionDisabled() || sendActionHidden()}- pending={sendMutation.isPending}- onClick={() => sendEmail()}- />+ <Show when={isMobileDrawer()}>+ <Layer depth={0}>+ <div+ data-corvu-no-drag=""+ class="sticky top-0 right-0 left-0 z-10 shrink-0 p-3 pt-0 flex items-center justify-between bg-surface"+ >+ <div class="flex items-center gap-1 min-w-0">+ <Button+ variant="ghost"+ size="icon-sm"+ class="rounded-full border border-edge-muted/70 bg-transparent"+ tooltip={savedDraftId() ? 'Delete draft' : 'Discard draft'}+ onClick={deleteDraftAndReset}+ >+ <Trash class="size-4" />+ </Button>+ </div>+ <div class="ml-auto flex items-center gap-1">+ <AttachButton+ variant="ghost"+ class="rounded-full border border-edge-muted/70 bg-transparent"+ />+ <SendButton+ disabled={sendActionDisabled() || sendActionHidden()}+ pending={sendMutation.isPending}+ onClick={() => sendEmail()}+ />+ </div></div>- </div>+ </Layer></Show><Showwhen={isMobileDrawer()}@@ -1841,6 +1794,7 @@ export function BaseInput(props: {links={emailLinksQuery.data?.links ?? []}activeLinkId={activeLinkId()}onSelect={persistDraftOnSenderSwitch}+ portalScope={composePortalScope()}/></div><div class="flex items-center ml-auto shrink-0">@@ -1982,19 +1936,14 @@ export function BaseInput(props: {</>}>- <div class="relative min-w-0 text-[17px] leading-6 text-ink-muted px-5 pt-1">+ <div class="pt-1 relative min-w-0 leading-6 text-ink-muted px-5"><RecipientDropRowfield="to"- class={cn(mobileDrawerRowClass, 'items-start py-2')}+ class={cn(mobileDrawerRowClass, 'items-center py-2')}dragState={recipientDragState}onDrop={handleRecipientDrop}>- <ReplyTypeDropdown- triggerVariant="ghost"- triggerSize="sm"- triggerClass="mt-0 h-[30px] shrink-0 rounded-full border border-edge-muted/70 bg-transparent px-2"- iconOnly- />+ <div class="shrink-0 text-ink-placeholder">To:</div><RecipientSelector<EmailRecipient['kind']>class={mobileRecipientSelectorClass}inputRef={setToRef}@@ -2012,32 +1961,22 @@ export function BaseInput(props: {}onChipDragEnd={handleChipDragEnd}/>- </RecipientDropRow>-- <div- class="min-h-14 border-b border-edge-muted/70 flex items-center min-w-0"- data-corvu-no-drag=""- >- <button- type="button"- class="shrink-0 text-left text-ink-placeholder"- onClick={() => {- setShowCc(true);- setShowBcc(true);- queueMicrotask(() => ccRef()?.focus());- }}+ <Button+ variant="ghost"+ size="icon-sm"+ class="shrink-0 rounded-full bg-transparent text-ink-placeholder"+ tooltip={mobileDrawerCcBccOpen() ? 'Hide Cc/Bcc' : 'Show Cc/Bcc'}+ aria-expanded={mobileDrawerCcBccOpen()}+ onClick={toggleMobileDrawerCcBcc}>- Cc/Bcc- </button>- <span class="shrink-0 text-ink-placeholder">, From: </span>- <FromInboxSelector- compact- class="min-w-0 truncate text-ink-muted"- links={emailLinksQuery.data?.links ?? []}- activeLinkId={activeLinkId()}- onSelect={persistDraftOnSenderSwitch}- />- </div>+ <Show+ when={mobileDrawerCcBccOpen()}+ fallback={<CaretRight class="size-4" />}+ >+ <ChevronDown class="size-4" />+ </Show>+ </Button>+ </RecipientDropRow><Show when={showCc() || form().recipients().cc.length > 0}><RecipientDropRow@@ -2095,6 +2034,21 @@ export function BaseInput(props: {</RecipientDropRow></Show>+ <div+ class="min-h-14 border-b border-edge-muted/70 flex items-center min-w-0"+ data-corvu-no-drag=""+ >+ <span class="shrink-0 text-ink-placeholder">From: </span>+ <FromInboxSelector+ compact+ class="min-w-0 truncate text-ink-muted"+ links={emailLinksQuery.data?.links ?? []}+ activeLinkId={activeLinkId()}+ onSelect={persistDraftOnSenderSwitch}+ portalScope={composePortalScope()}+ />+ </div>+<div class="min-h-14 border-b border-edge-muted/70 flex items-center"><inputtype="text"@@ -2112,7 +2066,7 @@ export function BaseInput(props: {<divclass={cn(isMobileDrawer()- ? 'relative flex-1 flex flex-col min-h-0'+ ? 'relative flex-1 flex flex-col': 'size-full flex flex-col min-h-0',showExpandedRecipients() && 'mt-4')}@@ -2133,10 +2087,10 @@ export function BaseInput(props: {<divref={setScrollContainer}class={cn(- 'relative min-h-18 max-h-[calc(60*var(--dvh,1dvh))] overflow-y-auto w-full flex flex-col placeholder:text-ink-placeholder placeholder:opacity-50 px-4 py-1',+ 'relative min-h-18 w-full flex flex-col placeholder:text-ink-placeholder placeholder:opacity-50 px-4 py-1',isMobileDrawer()- ? 'mobile:max-h-none flex-1 min-h-0 px-5 pt-6 pb-4'- : 'mobile:max-h-[calc(32*var(--dvh,1dvh))]'+ ? 'max-h-none flex-1 overflow-visible px-5 pt-6 pb-4'+ : 'max-h-[calc(60*var(--dvh,1dvh))] overflow-y-auto mobile:max-h-[calc(32*var(--dvh,1dvh))]')}onclick={() => {editor()?.focus();@@ -2187,7 +2141,7 @@ export function BaseInput(props: {? 'Use `@` to reference files': 'Reply — @mention to share or cc people'}- portalScope="split"+ portalScope={isMobileDrawer() ? 'local' : 'split'}refFn={(el) => props.markdownDomRef?.(el)}onConnect={handleEditorConnect}/>diff --git a/js/app/packages/block-email/component/EmailInput.tsx b/js/app/packages/block-email/component/EmailInput.tsxindex 6780aca379..cc558e577d 100644--- a/js/app/packages/block-email/component/EmailInput.tsx+++ b/js/app/packages/block-email/component/EmailInput.tsx@@ -47,7 +47,7 @@ export function EmailInput(props: EmailInputProps) {return (<Show when={ctx.drafts.initialDraftsSettled()}>- <Layer depth={2}>+ <Layer depth={props.mobileDrawer ? 0 : 2}><BaseInputreplyingTo={props.replyingTo}draft={props.draft}diff --git a/js/app/packages/block-email/component/FromInboxSelector.tsx b/js/app/packages/block-email/component/FromInboxSelector.tsxindex 5b2d1c4745..f380db3876 100644--- a/js/app/packages/block-email/component/FromInboxSelector.tsx+++ b/js/app/packages/block-email/component/FromInboxSelector.tsx@@ -44,6 +44,7 @@ export function FromInboxSelector(props: {onSelect: (linkId: string) => void;compact?: boolean;class?: string;+ portalScope?: 'local';}) {const activeInbox = () =>props.links.find((l) => l.id === props.activeLinkId) ?? props.links[0];@@ -67,7 +68,7 @@ export function FromInboxSelector(props: {<span class="min-w-0 truncate">{active().email_address}</span><ChevronDown class="size-3 shrink-0" /></Dropdown.Trigger>- <Dropdown.Content>+ <Dropdown.Content portalScope={props.portalScope}><Dropdown.Group><For each={sortedLinks()}>{(inbox) => (@@ -108,7 +109,7 @@ export function FromInboxSelector(props: {</Show><ChevronDown class="size-3 shrink-0" /></Dropdown.Trigger>- <Dropdown.Content>+ <Dropdown.Content portalScope={props.portalScope}><Dropdown.Group><For each={sortedLinks()}>{(inbox) => (diff --git a/js/app/packages/block-email/component/MobileEmailComposeDrawer.tsx b/js/app/packages/block-email/component/MobileEmailComposeDrawer.tsxindex 34844dab8d..a8a85046c9 100644--- a/js/app/packages/block-email/component/MobileEmailComposeDrawer.tsx+++ b/js/app/packages/block-email/component/MobileEmailComposeDrawer.tsx@@ -1,26 +1,12 @@-import { MobileDrawer } from '@app/component/mobile/MobileDrawer';+import {+ MobileDrawer,+ scrollToFocusedInput,+} from '@app/component/mobile/MobileDrawer';import { FloatingInputLoader } from '@core/component/FloatingInputLoader';import { createMemo, Show } from 'solid-js';import { useEmailContext } from './EmailContext';import { EmailInput } from './EmailInput';-const DEFAULT_DRAWER_SNAP = 0.75;-const EXPANDED_DRAWER_SNAP = 0.92;--function drawerHeightStyle(openPercentage: number) {- const height = `${Math.round(- Math.max(- DEFAULT_DRAWER_SNAP,- Math.min(EXPANDED_DRAWER_SNAP, openPercentage)- ) * 100- )}dvh`;-- return {- height,- 'max-height': height,- };-}-export function MobileEmailComposeDrawer(props: {markdownDomRef?: (ref: HTMLDivElement) => void | HTMLDivElement;}) {@@ -60,48 +46,47 @@ export function MobileEmailComposeDrawer(props: {onOpenChange={setDrawerOpen}preventScroll={false}preventScrollbarShift={false}- snapPoints={[DEFAULT_DRAWER_SNAP, EXPANDED_DRAWER_SNAP]}- defaultSnapPoint={DEFAULT_DRAWER_SNAP}+ breakPoints={[0.85]}>- {(drawer) => (- <MobileDrawer.Portal>- <MobileDrawer.Overlay class="fixed inset-0 z-modal-overlay bg-modal-overlay pattern-diagonal-4 pattern-edge-muted" />- <MobileDrawer.Content- aria-label="Reply composer"- class="!h-[100dvh] !max-h-[100dvh] overflow-hidden pb-0"- >+ <MobileDrawer.Portal>+ <MobileDrawer.Overlay class="fixed inset-0 z-modal-overlay bg-modal-overlay pattern-diagonal-4 pattern-edge-muted" />+ <MobileDrawer.Content+ aria-label="Reply composer"+ maxHeight={90}+ targetHeight={90}+ >+ <MobileDrawer.Handle class="pb-1" />++ <div class="relative flex-1 min-h-0">+ <FloatingInputLoader+ isLoading={context.query.isFetching}+ loadingText="Loading messages"+ /><div- class="min-h-0 flex flex-col"- style={drawerHeightStyle(drawer.openPercentage)}+ class="overflow-y-auto scrollbar-hidden h-full pb-1"+ onFocusIn={(e) => scrollToFocusedInput(e)}>- <MobileDrawer.Handle class="pb-1" />- <div class="relative min-h-0 flex-1 flex flex-col">- <FloatingInputLoader- isLoading={context.query.isFetching}- loadingText="Loading messages"- />- <EmailInput- replyingTo={() => info().replyingTo}- draft={info().draft}- setShowReply={(value) => {- const next =- typeof value === 'function'- ? value(context.mobileReplyComposer.open())- : value;- setDrawerOpen(next);- return next;- }}- markdownDomRef={props.markdownDomRef}- unframed- mobileDrawer={{- onClose: () => setDrawerOpen(false),- }}- />- </div>+ <EmailInput+ replyingTo={() => info().replyingTo}+ draft={info().draft}+ setShowReply={(value) => {+ const next =+ typeof value === 'function'+ ? value(context.mobileReplyComposer.open())+ : value;+ setDrawerOpen(next);+ return next;+ }}+ markdownDomRef={props.markdownDomRef}+ unframed+ mobileDrawer={{+ onClose: () => setDrawerOpen(false),+ }}+ /></div>- </MobileDrawer.Content>- </MobileDrawer.Portal>- )}+ </div>+ </MobileDrawer.Content>+ </MobileDrawer.Portal></MobileDrawer>)}</Show>diff --git a/js/app/packages/core/component/RecipientSelector.tsx b/js/app/packages/core/component/RecipientSelector.tsxindex c4ea36a381..f571a437ec 100644--- a/js/app/packages/core/component/RecipientSelector.tsx+++ b/js/app/packages/core/component/RecipientSelector.tsx@@ -277,6 +277,7 @@ type RecipientSelectorProps<K extends CombinedRecipientKind> = {horizontalScroll?: boolean;class?: string;depth?: 0 | 1 | 2 | 3 | 4 | 5;+ portalScope?: 'local';};export function RecipientSelector<K extends CombinedRecipientKind>(@@ -290,6 +291,18 @@ export function RecipientSelector<K extends CombinedRecipientKind>(const [disabled, setDisabled] = createSignal(false);const [listboxRef, setListboxRef] = createSignal<HTMLElement | undefined>();+ const [portalSearchRef, setPortalSearchRef] = createSignal<+ HTMLDivElement | undefined+ >();++ const portalMount = () => {+ if (props.portalScope !== 'local') return undefined;+ return (+ 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.@@ -337,9 +350,7 @@ export function RecipientSelector<K extends CombinedRecipientKind>(}const placeholderText = () => {- return props.selectedOptions.length === 0- ? 'Select recipients'- : 'select more recipients';+ return props.selectedOptions.length === 0 ? 'Select recipients' : undefined;};const userId = useUserId();@@ -747,6 +758,7 @@ export function RecipientSelector<K extends CombinedRecipientKind>(}}class="flex-1 min-h-7 p-1 min-w-50 outline-none placeholder:text-ink-placeholder"classList={{ 'ml-1': selectedLen() === 0 }}+ onFocus={() => setIsOpen(true)}onKeyDown={(e) => {if ((e.key === 'a' && e.ctrlKey) ||@@ -789,58 +801,61 @@ export function RecipientSelector<K extends CombinedRecipientKind>(}}</Combobox.Control>- <Combobox.Portal>- <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',- });+ <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',+ });+ }}- }- });-- 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>+ });++ 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><Combobox.ErrorMessage class="text-xs text-failure mt-1">*At least one participant is required</Combobox.ErrorMessage>