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(recipient-selector): fix focus lock in recip selector combo box (#5555)
Seamus29851d3e81e4
diff --git a/apps/web/src/lib/core/component/RecipientSelector.tsx b/apps/web/src/lib/core/component/RecipientSelector.tsxindex d42dea58a9..2e9d20d699 100644--- a/apps/web/src/lib/core/component/RecipientSelector.tsx+++ b/apps/web/src/lib/core/component/RecipientSelector.tsx@@ -321,7 +321,14 @@ export function RecipientSelector<K extends CombinedRecipientKind>(const debouncedHandleChange = debounce(handleChange, 100);- const [isOpen, setIsOpen] = createSignal<boolean>();+ const [isOpen, setIsOpen] = createSignal(false);+ const [suppressOpenUntilInputChange, setSuppressOpenUntilInputChange] =+ createSignal(Boolean(props.focusOnMount));++ const setComboboxOpen = (next: boolean) => {+ if (next && suppressOpenUntilInputChange()) return;+ setIsOpen(next);+ };const hasValidCustomEmail = () => {const input = inputValue();@@ -331,7 +338,7 @@ export function RecipientSelector<K extends CombinedRecipientKind>(createEffect(() => {if (hasValidCustomEmail()) {- setIsOpen(true);+ setComboboxOpen(true);}});@@ -573,10 +580,14 @@ export function RecipientSelector<K extends CombinedRecipientKind>(let contentEl: HTMLElement | undefined;const onInputChange = (next: string) => {+ const previous = inputValue();setInputValue(next);- if (next.length > 0) {- setIsOpen(true);+ if (next !== previous) {+ setSuppressOpenUntilInputChange(false);}+ if (next.length === 0) return;++ setIsOpen(true);// 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@@ -596,7 +607,7 @@ export function RecipientSelector<K extends CombinedRecipientKind>(triggerMode={props.triggerMode ?? 'input'}closeOnSelection={true}open={isOpen()}- onOpenChange={setIsOpen}+ onOpenChange={setComboboxOpen}disabled={props.disabled}validationState={invalid() ? 'invalid' : 'valid'}options={optionsWithSelected()}@@ -765,7 +776,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={() => {- if (props.openOnFocus ?? true) setIsOpen(true);+ if (props.openOnFocus ?? true) setComboboxOpen(true);}}onKeyDown={(e) => {if (@@ -775,21 +786,15 @@ export function RecipientSelector<K extends CombinedRecipientKind>(setDisabled(true);queueMicrotask(() => setDisabled(false));}- if (e.key === 'Escape') {- if (inputValue().length === 0) {- inputRef()?.blur();- }- }}}// use a non-delegated event here so that we can process it before Kobalteon:keydown={(e: KeyboardEvent) => {- if (- e.key === 'Escape' &&- props.hideMenuOnEscape &&- context.isOpen()- ) {+ if (e.key === 'Escape' && isOpen()) {e.preventDefault();- e.stopPropagation();+ if (props.hideMenuOnEscape) {+ e.stopPropagation();+ }+ setSuppressOpenUntilInputChange(true);setIsOpen(false);return;}