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): focus the Cc and Bcc fields their buttons reveal (#9287)

teoc5fca1612362
diff --git a/apps/web/src/features/email-compose/browser-test/recipient-hotkeys.app.e2e.ts b/apps/web/src/features/email-compose/browser-test/recipient-hotkeys.app.e2e.ts
index 0207f95026..012b76905e 100644
--- a/apps/web/src/features/email-compose/browser-test/recipient-hotkeys.app.e2e.ts
+++ b/apps/web/src/features/email-compose/browser-test/recipient-hotkeys.app.e2e.ts
@@ -35,4 +35,29 @@ for (const composer of ['new', 'reply', 'reply-all', 'forward']) {
await expect(cc).toBeFocused();
await expect(page.getByTestId('thread-command')).toHaveText('none');
});
+
+ test(`clicking Cc and Bcc focuses the revealed field in the ${composer} composer`, async ({
+ page,
+ }) => {
+ await page.goto(
+ `/src/features/email-compose/browser-test/recipient-hotkeys.html?composer=${composer}`
+ );
+ await page.locator('[contenteditable="true"]').waitFor();
+ // Replies open with their recipients collapsed into a summary.
+ if (composer === 'reply' || composer === 'reply-all') {
+ await page.getByRole('button', { name: /^Replying to/ }).click();
+ }
+
+ for (const field of ['Cc', 'Bcc']) {
+ await page.getByRole('button', { name: field, exact: true }).click();
+ const input = page
+ .getByText(field, { exact: true })
+ .locator('..')
+ .getByRole('combobox');
+ await expect(input).toBeFocused();
+ // Typing lands in the field instead of reaching the app's hotkeys.
+ await page.keyboard.type('cq');
+ await expect(input).toHaveValue('cq');
+ }
+ });
}
diff --git a/apps/web/src/features/email-compose/primitives/cc-bcc-hotkeys.ts b/apps/web/src/features/email-compose/primitives/cc-bcc-hotkeys.ts
index 7041061114..3af43f9ce3 100644
--- a/apps/web/src/features/email-compose/primitives/cc-bcc-hotkeys.ts
+++ b/apps/web/src/features/email-compose/primitives/cc-bcc-hotkeys.ts
@@ -7,6 +7,12 @@ type RecipientField = {
input: () => HTMLElement | undefined;
};
+/** Shows a Cc or Bcc field and focuses its input once the field mounts. */
+export function revealRecipientField(field: RecipientField) {
+ field.reveal();
+ queueMicrotask(() => field.input()?.focus());
+}
+
/**
* Cmd+Shift+C and Cmd+Shift+B reveal and focus the Cc and Bcc fields. Each
* composer registers them on its own scope, because the enclosing split binds
@@ -20,9 +26,7 @@ export function registerCcBccHotkeys(options: {
}) {
const edit = (field: RecipientField) => () => {
if (options.disabled()) return false;
- field.reveal();
- // The field mounts on reveal; focus it once its input ref is set.
- queueMicrotask(() => field.input()?.focus());
+ revealRecipientField(field);
return true;
};
registerHotkey({
diff --git a/apps/web/src/features/email-compose/views/compose-layout.tsx b/apps/web/src/features/email-compose/views/compose-layout.tsx
index a336a461d9..7b02e97d61 100644
--- a/apps/web/src/features/email-compose/views/compose-layout.tsx
+++ b/apps/web/src/features/email-compose/views/compose-layout.tsx
@@ -14,7 +14,10 @@ import {
import { Dynamic } from 'solid-js/web';
import { FromInboxSelector } from '../components/from-inbox-selector';
import { useCompose } from '../context/compose-context';
-import { registerCcBccHotkeys } from '../primitives/cc-bcc-hotkeys';
+import {
+ registerCcBccHotkeys,
+ revealRecipientField,
+} from '../primitives/cc-bcc-hotkeys';
import { registerDraftActionHotkeys } from '../primitives/draft-action-hotkeys';
import { ComposeBody } from './compose-body';
import { ComposeRecipients } from './compose-recipients';
@@ -126,17 +129,20 @@ export function ComposeLayout(props: {
shouldReturnFocusOnClose: false,
});
+ const ccField = {
+ reveal: () => setShowCc(true),
+ input: () => refs().ccRecipientsSelector,
+ };
+ const bccField = {
+ reveal: () => setShowBcc(true),
+ input: () => refs().bccRecipientsSelector,
+ };
+
registerCcBccHotkeys({
scopeId: composeHotkeyScope,
disabled: ctx.disabled,
- cc: {
- reveal: () => setShowCc(true),
- input: () => refs().ccRecipientsSelector,
- },
- bcc: {
- reveal: () => setShowBcc(true),
- input: () => refs().bccRecipientsSelector,
- },
+ cc: ccField,
+ bcc: bccField,
});
registerHotkey({
@@ -268,7 +274,7 @@ export function ComposeLayout(props: {
<Button
variant="ghost"
size="sm"
- onClick={() => setShowCc(true)}
+ onClick={() => revealRecipientField(ccField)}
disabled={ctx.disabled()}
>
Cc
@@ -278,7 +284,7 @@ export function ComposeLayout(props: {
<Button
variant="ghost"
size="sm"
- onClick={() => setShowBcc(true)}
+ onClick={() => revealRecipientField(bccField)}
disabled={ctx.disabled()}
>
Bcc
diff --git a/docs/agent-guide/email.md b/docs/agent-guide/email.md
index 930d42035a..830dd4bc8c 100644
--- a/docs/agent-guide/email.md
+++ b/docs/agent-guide/email.md
@@ -618,9 +618,10 @@ and type; every character must stay in Subject.
In new emails, replies, reply-alls, and forwards, `Cmd+Shift+C` (`Ctrl+Shift+C`)
reveals and focuses Cc and `Cmd+Shift+B` does the same for Bcc, expanding a
collapsed reply header; inside a composer they never fall through to the
-thread's Copy link. `bunx playwright test --config
-src/features/email-compose/browser-test/playwright.app.config.ts` (from
-`apps/web`) checks both shortcuts in all four composers.
+thread's Copy link. Clicking the Cc or Bcc button also focuses the revealed
+field, so typing goes there instead of to app shortcuts. `bunx playwright test
+--config src/features/email-compose/browser-test/playwright.app.config.ts` (from
+`apps/web`) checks both shortcuts and both buttons in all four composers.
While an editable field is focused, Escape is handled by that field before the
close-reply shortcut.
An edited reply remains a draft when navigating away and returning. Standalone