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: Auto focus first item in recipient selector when typing and mount (#488)
dev-rbe2618c24e6d4
diff --git a/js/app/packages/core/component/RecipientSelector.tsx b/js/app/packages/core/component/RecipientSelector.tsxindex 7f555910e6..5560f4fced 100644--- a/js/app/packages/core/component/RecipientSelector.tsx+++ b/js/app/packages/core/component/RecipientSelector.tsx@@ -230,6 +230,8 @@ export function RecipientSelector<K extends CombinedRecipientKind>();const [disabled, setDisabled] = createSignal(false);+ const [listboxRef, setListboxRef] = createSignal<HTMLElement | undefined>();+const debouncedHandleChange = debounce(handleChange, 100);const [isOpen, setIsOpen] = createSignal<boolean>();@@ -380,8 +382,22 @@ export function RecipientSelector<K extends CombinedRecipientKind>(const [scrollToItem, setScrollToItem] = createSignal<(key: string) => void>(() => {});+const selectedLen = () => props.selectedOptions().length;+ const onInputChange = (next: string) => {+ setInputValue(next);++ // Send the keydown event to the listbox so Kobalte's internal system can update the focus state+ // This makes it so it behaves the same as if you had manually pressed the down arrow to focus the item+ queueMicrotask(() => {+ listboxRef()?.dispatchEvent(+ // We need to send `bubbles: true` because otherwise Kobalte ignores the event+ new KeyboardEvent('keydown', { bubbles: true, key: 'ArrowDown' })+ );+ });+ };+return (<Combobox<CombinedRecipientItem>multiple@@ -399,7 +415,8 @@ export function RecipientSelector<K extends CombinedRecipientKind>(optionDisabled={getOptionDisabled}value={props.selectedOptions() as CombinedRecipientItem[]}onChange={debouncedHandleChange}- onInputChange={setInputValue}+ onInputChange={onInputChange}+ shouldFocusWrapplaceholder={props.selectedOptions()?.length === 0? (props.placeholder ?? placeholderText())@@ -514,8 +531,10 @@ export function RecipientSelector<K extends CombinedRecipientKind>(<Combobox.Portal><Combobox.Content class="z-modal-content bg-menu border translate-y-1 border-edge p-1"><Combobox.Listbox+ ref={setListboxRef}class="flex flex-col gap-1"scrollToItem={scrollToItem()}+ autoFocus="first">{(items) => {const arr = Array.from(items());