From 0e3918f32aa7c42c880cf691c2783e9a6180cb4c Mon Sep 17 00:00:00 2001 From: Arjun <6592213+arkml@users.noreply.github.com> Date: Sat, 11 Jul 2026 10:35:24 +0530 Subject: [PATCH] fix(x): stop clipping the last line of short email bodies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A message body whose first block has a top margin (a bare
, most Outlook mail) rendered with its final line cut off. The margin collapses through
, so body.scrollHeight under-reports by the margin height while the content's real bottom sits lower — and that short height is what we set on the iframe. Measured in Electron: a two-line reply reported 63px against a 73px content bottom, losing 10px. display: flow-root on contains the margin (the existing rule only reset the *last* child's bottom margin). Pre-existing; not caused by quote collapsing. Also restore attributes when re-serializing a prepared body. prepareEmailHtml joined head.innerHTML + body.innerHTML, dropping the tag — and with it the bgcolor/style that 431 of 584 local messages rely on for their background (the host parser merges a nested 's attributes onto its own). Serialize documentElement.innerHTML instead so the tag and its attributes survive. Co-Authored-By: Claude Opus 4.8 (1M context)Hi
') + expect(html).toContain('bgcolor="#f4f4f4"') + expect(html).toContain('margin:0') + }) + it('ignores quoted content when deciding whether the email is styled', () => { // The table lives only in the quote, so the body should still adapt to theme. const { styled } = prepareEmailHtml( diff --git a/apps/x/apps/renderer/src/lib/email-quotes.ts b/apps/x/apps/renderer/src/lib/email-quotes.ts index 37fdd553..d69cd3f2 100644 --- a/apps/x/apps/renderer/src/lib/email-quotes.ts +++ b/apps/x/apps/renderer/src/lib/email-quotes.ts @@ -143,10 +143,12 @@ export function prepareEmailHtml(rawHtml: string): PreparedEmail { const doc = new DOMParser().parseFromString(rawHtml, 'text/html') const hasQuote = markQuotedNodes(doc) && unmarkIfNothingRemains(doc) const styled = isStyledDocument(doc) - // Emails ship