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(email-compose): keep chips and typed text on Enter over an invalid address (#9288)

teo36a165b73753
diff --git a/apps/web/src/lib/core/component/RecipientSelector.test.tsx b/apps/web/src/lib/core/component/RecipientSelector.test.tsx
index a141e29592..167875acff 100644
--- a/apps/web/src/lib/core/component/RecipientSelector.test.tsx
+++ b/apps/web/src/lib/core/component/RecipientSelector.test.tsx
@@ -98,6 +98,15 @@ describe('RecipientSelector typed addresses', () => {
expect(input.value).toBe('');
});
+ it('keeps the recipients and the text when Enter is pressed on an invalid address', async () => {
+ const user = userEvent.setup();
+ const { input, emails } = renderSelector();
+ fireEvent.input(input, { target: { value: '[email protected],' } });
+ await user.type(input, 'notanemail{Enter}');
+ expect(emails()).toEqual(['[email protected]']);
+ expect(input.value).toBe('notanemail');
+ });
+
it('leaves text until a separator ends a complete address', () => {
const { input, emails } = renderSelector();
fireEvent.input(input, {
diff --git a/apps/web/src/lib/core/component/RecipientSelector.tsx b/apps/web/src/lib/core/component/RecipientSelector.tsx
index d86a38ed83..f6c5e214c4 100644
--- a/apps/web/src/lib/core/component/RecipientSelector.tsx
+++ b/apps/web/src/lib/core/component/RecipientSelector.tsx
@@ -422,9 +422,6 @@ export function RecipientSelector<K extends CombinedRecipientKind>(
): JSX.Element {
const [inputRef, setInputRef] = createSignal<HTMLInputElement>();
const [inputValue, setInputValue] = createSignal('');
- const [customUsers, setCustomUsers] = createSignal<WithCustomUserInput<K>[]>(
- []
- );
const [disabled, setDisabled] = createSignal(false);
const [listboxRef, setListboxRef] = createSignal<HTMLElement | undefined>();
@@ -507,7 +504,6 @@ export function RecipientSelector<K extends CombinedRecipientKind>(
function handleChange(value: CombinedRecipientItem[]) {
let newestSelection = value.at(-1);
if (!newestSelection) {
- setCustomUsers([]);
props.setSelectedOptions([]);
return;
}
@@ -535,14 +531,6 @@ export function RecipientSelector<K extends CombinedRecipientKind>(
newestSelection.kind === 'custom' ||
newestSelection.kind === 'agent'
) {
- setCustomUsers(
- value.filter((o) => {
- if (o.kind === 'custom') {
- return o.data.invalid === false;
- }
- return false;
- }) as WithCustomUserInput<K>[]
- );
props.setSelectedOptions(value as CombinedRecipientItem<K>[]);
return;
}
@@ -690,10 +678,12 @@ export function RecipientSelector<K extends CombinedRecipientKind>(
typed.push(recipientEntityMapper('custom')(customUserInput));
}
- return [
- ...rankRecipientMatches([...searched, ...typed], searchTerm),
- ...customUsers(),
- ] as CombinedRecipientItem<K>[];
+ // Typed recipients already chosen stay out of the suggestions, where Enter
+ // on text matching nothing would toggle one off and clear the text.
+ return rankRecipientMatches(
+ [...searched, ...typed],
+ searchTerm
+ ) as CombinedRecipientItem<K>[];
});
const visibleOptionKeys = createMemo(
diff --git a/docs/agent-guide/email.md b/docs/agent-guide/email.md
index 830dd4bc8c..f85e867cd9 100644
--- a/docs/agent-guide/email.md
+++ b/docs/agent-guide/email.md
@@ -679,6 +679,10 @@ missing message or subject error does once filled in. Suggestions leave out
automated addresses (`notifications@`, `mailer-daemon@`, `postmaster@`,
`bounce@` and no-reply or do-not-reply addresses); typing one in full still adds
it. Reply on a bounce goes to its sender, as for any other message.
+With a typed address chip in To or Cc, type text that is not an address
+(`notanemail`) and press Enter, or `bad@@x..com` and Tab: the chip stays, and
+the text stays in the field to be corrected. A typed address already chosen is
+not listed again in the suggestions.
When checking draft autosave, edit the body of a draft with uploaded or forwarded
attachments, wait for the save, and reopen it; the attachments should remain visible.
In a long thread, scroll away from the bottom while a draft save is pending.