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): focus editor when opening reply (#3236)

Evan Hutnikc83e9107e406
diff --git a/js/app/packages/block-email/component/BaseInput.tsx b/js/app/packages/block-email/component/BaseInput.tsx
index 1d82166a05..ef4b63e1a2 100644
--- a/js/app/packages/block-email/component/BaseInput.tsx
+++ b/js/app/packages/block-email/component/BaseInput.tsx
@@ -610,6 +610,10 @@ export function BaseInput(props: {
toRef()?.focus();
}
}, 100);
+ } else if (rt === 'reply' || rt === 'reply-all') {
+ setTimeout(() => {
+ editor()?.focus();
+ }, 100);
}
});
});
@@ -1152,18 +1156,22 @@ export function BaseInput(props: {
}
});
- // Focus when external shouldFocus signal is set to true
+ // Focus when external shouldFocus signal is set to true. Gated on
+ // editor() so the effect re-runs once the Lexical editor is captured —
+ // when the input is freshly mounted (e.g. opening from BottomReplyButtons),
+ // shouldFocusInput is true before captureEditor fires.
createEffect(() => {
- if (form().shouldFocusInput()) {
- if (!isMobile()) {
- requestAnimationFrame(() => {
- editor()?.focus();
- form().setShouldFocusInput(false);
- });
- } else {
- form().setShouldFocusInput(false);
- }
+ if (!form().shouldFocusInput()) return;
+ if (isMobile()) {
+ form().setShouldFocusInput(false);
+ return;
}
+ const ed = editor();
+ if (!ed) return;
+ requestAnimationFrame(() => {
+ ed.focus();
+ form().setShouldFocusInput(false);
+ });
});
const handleAddAttachments = (files: File[]) => {