From e78ed0f007e5f017e6b10798e17460966769acd5 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Tue, 3 Nov 2026 07:13:03 +0100 Subject: [PATCH] fix: bring the quick reply's buttons into view when it takes the focus --- .../email/__tests__/reader-plugin-surfaces.test.tsx | 11 +++++++++++ components/email/email-viewer.tsx | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/components/email/__tests__/reader-plugin-surfaces.test.tsx b/components/email/__tests__/reader-plugin-surfaces.test.tsx index 07687a71f..28d5f4745 100644 --- a/components/email/__tests__/reader-plugin-surfaces.test.tsx +++ b/components/email/__tests__/reader-plugin-surfaces.test.tsx @@ -425,6 +425,17 @@ describe('reader surfaces in the phone conversation view', () => { }); }); +describe('quick reply', () => { + it('scrolls its buttons into view when it takes the focus', () => { + const scroll = vi.fn(); + Element.prototype.scrollIntoView = scroll; + useSettingsStore.setState({ quickReplyEnabled: true }); + const { container } = viewer(textMail('Hola'), { onQuickReply: vi.fn() }); + fireEvent.focus(container.querySelector('textarea')!); + expect(scroll).toHaveBeenCalledWith({ block: 'nearest' }); + }); +}); + describe('recipients row', () => { it('says how many recipients are left out, in the phone row as in the desktop one', () => { const to = ['a', 'b', 'c', 'd'].map((n) => ({ name: n, email: `${n}@example.com` })); diff --git a/components/email/email-viewer.tsx b/components/email/email-viewer.tsx index 11f1913cb..ed900dcec 100644 --- a/components/email/email-viewer.tsx +++ b/components/email/email-viewer.tsx @@ -1613,6 +1613,11 @@ export function EmailViewer({ const [quickReplyText, setQuickReplyText] = useState(""); const quickReplyRef = useRef(null); const [isQuickReplyFocused, setIsQuickReplyFocused] = useState(false); + const quickReplyBoxRef = useRef(null); + // Focused, the box grows by its buttons: bring them up, they'd sit below the fold. + useEffect(() => { + if (isQuickReplyFocused) quickReplyBoxRef.current?.scrollIntoView?.({ block: 'nearest' }); + }, [isQuickReplyFocused]); const [isSendingQuickReply, setIsSendingQuickReply] = useState(false); /** The recipients and identity the quick reply would be sent with. */ const quickMetadata = (): ComposerMetadata => { @@ -5937,7 +5942,7 @@ ${printWatermark ? printWatermark.html : ''} )} {/* Quick Reply Section - hidden for drafts and while loading a new email */} - {showQuickReply && (
+ {showQuickReply && (