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(recipient-selector): fix nits for recip selector focus and layout (#5434)

Seamus53145587d761
diff --git a/apps/web/src/features/block-email/component/BaseInput.tsx b/apps/web/src/features/block-email/component/BaseInput.tsx
index 2d082353db..e9b024c5a5 100644
--- a/apps/web/src/features/block-email/component/BaseInput.tsx
+++ b/apps/web/src/features/block-email/component/BaseInput.tsx
@@ -1730,6 +1730,7 @@ export function BaseInput(props: {
handleChipDragStart('to', option, e)
}
onChipDragEnd={handleChipDragEnd}
+ hideMenuOnEscape
/>
</RecipientDropRow>
{/* Expanded CC */}
@@ -1760,6 +1761,7 @@ export function BaseInput(props: {
handleChipDragStart('cc', option, e)
}
onChipDragEnd={handleChipDragEnd}
+ hideMenuOnEscape
/>
</RecipientDropRow>
</Show>
@@ -1791,6 +1793,7 @@ export function BaseInput(props: {
handleChipDragStart('bcc', option, e)
}
onChipDragEnd={handleChipDragEnd}
+ hideMenuOnEscape
/>
</RecipientDropRow>
</Show>
@@ -1844,6 +1847,7 @@ export function BaseInput(props: {
handleChipDragStart('to', option, e)
}
onChipDragEnd={handleChipDragEnd}
+ hideMenuOnEscape
/>
<Button
variant="ghost"
@@ -1888,6 +1892,7 @@ export function BaseInput(props: {
handleChipDragStart('cc', option, e)
}
onChipDragEnd={handleChipDragEnd}
+ hideMenuOnEscape
/>
</RecipientDropRow>
</Show>
@@ -1918,6 +1923,7 @@ export function BaseInput(props: {
handleChipDragStart('bcc', option, e)
}
onChipDragEnd={handleChipDragEnd}
+ hideMenuOnEscape
/>
</RecipientDropRow>
</Show>
diff --git a/apps/web/src/features/block-email/component/compose/ComposeLayout.tsx b/apps/web/src/features/block-email/component/compose/ComposeLayout.tsx
index 7553ca981c..2d9b87858b 100644
--- a/apps/web/src/features/block-email/component/compose/ComposeLayout.tsx
+++ b/apps/web/src/features/block-email/component/compose/ComposeLayout.tsx
@@ -207,13 +207,15 @@ export function ComposeLayout(props: {
}
>
<Show when={ctx.fromAddress?.()}>
- <div class="text-xs text-ink-extra-muted/50 flex items-center gap-1 min-w-0">
- <span class="shrink-0">from</span>
- <FromInboxSelector
- links={ctx.fromInboxes?.() ?? []}
- activeLinkId={ctx.selectedFromLinkId?.()}
- onSelect={(id) => ctx.onSelectFromLink?.(id)}
- />
+ <div class="text-xs text-ink-extra-muted/50 flex items-center gap-2 min-w-0 flex-1">
+ <span class="w-14 shrink-0">from</span>
+ <div class="min-w-0">
+ <FromInboxSelector
+ links={ctx.fromInboxes?.() ?? []}
+ activeLinkId={ctx.selectedFromLinkId?.()}
+ onSelect={(id) => ctx.onSelectFromLink?.(id)}
+ />
+ </div>
</div>
</Show>
</Suspense>
diff --git a/apps/web/src/features/block-email/component/compose/ComposeRecipients.tsx b/apps/web/src/features/block-email/component/compose/ComposeRecipients.tsx
index b40b82fa12..1f991333a7 100644
--- a/apps/web/src/features/block-email/component/compose/ComposeRecipients.tsx
+++ b/apps/web/src/features/block-email/component/compose/ComposeRecipients.tsx
@@ -211,6 +211,7 @@ export function ComposeRecipients(props: {
}}
placeholder={isMobile() ? '' : 'Macro users or email addresses'}
focusOnMount={opts?.focusOnMount}
+ openOnFocus={false}
hideBorder
class={cn(
'bg-transparent [&_input]:ml-0!',
@@ -221,6 +222,7 @@ export function ComposeRecipients(props: {
includeSelf={opts?.includeSelf}
onChipDragStart={(option, e) => handleChipDragStart(field, option, e)}
onChipDragEnd={handleChipDragEnd}
+ hideMenuOnEscape
/>
);
diff --git a/apps/web/src/lib/core/component/RecipientSelector.tsx b/apps/web/src/lib/core/component/RecipientSelector.tsx
index a6c419fea9..d42dea58a9 100644
--- a/apps/web/src/lib/core/component/RecipientSelector.tsx
+++ b/apps/web/src/lib/core/component/RecipientSelector.tsx
@@ -276,6 +276,7 @@ type RecipientSelectorProps<K extends CombinedRecipientKind> = {
disabled?: boolean;
onChipDragStart?: (option: WithCustomUserInput<K>, e: DragEvent) => void;
onChipDragEnd?: (e: DragEvent) => void;
+ hideMenuOnEscape?: boolean;
horizontalScroll?: boolean;
class?: string;
depth?: 0 | 1 | 2 | 3 | 4 | 5;
@@ -573,6 +574,9 @@ export function RecipientSelector<K extends CombinedRecipientKind>(
const onInputChange = (next: string) => {
setInputValue(next);
+ if (next.length > 0) {
+ 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
@@ -779,6 +783,17 @@ export function RecipientSelector<K extends CombinedRecipientKind>(
}}
// use a non-delegated event here so that we can process it before Kobalte
on:keydown={(e: KeyboardEvent) => {
+ if (
+ e.key === 'Escape' &&
+ props.hideMenuOnEscape &&
+ context.isOpen()
+ ) {
+ e.preventDefault();
+ e.stopPropagation();
+ setIsOpen(false);
+ return;
+ }
+
if (e.key === 'Tab' && context.isOpen()) {
e.preventDefault();
e.stopPropagation();