Skip to content

fix: remove logic modifying inbound email CSS for padding.#438

Open
maxhaomh wants to merge 1 commit into
bulwarkmail:mainfrom
maxhaomh:fix/email-viewer-css
Open

fix: remove logic modifying inbound email CSS for padding.#438
maxhaomh wants to merge 1 commit into
bulwarkmail:mainfrom
maxhaomh:fix/email-viewer-css

Conversation

@maxhaomh

@maxhaomh maxhaomh commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

The logic of modifying email CSS based on unreliable heuristics can break HTML styling and rendering in unpredictable ways. Injecting Body Padding into the email itself, based on the presence of <style>, is unreliable, as many edge cases have not been accounted for, as seen in #433 with Outlook Web App. Beyond Outlook, there are certain marketing emails that may ship with a <style> tag but lack proper gutter/padding—in general, there are too many edge cases to make this method reliable.

This PR removes the CSS modifications (besides dark mode) and adds padding to the JSX wrapper itself. Email messages are rendered as is.

Changes

  • Removed all heuristic-based CSS injection logic: isWordHtml, hasOwnLayout, bodyPadding, mobileBodyPaddingX, wordHtmlCSS. The email should handle mobile responsiveness itself.
  • Stripped injected <style> block: (font-family, font-size, line-height, color, background, word-wrap, overflow-wrap, conditional padding/mobile media query). Removed ${wordHtmlCSS} interpolation.
  • Moved padding from injected CSS to the JSX wrapper itself

Related Issues

Closes #433

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactor / code quality improvement
  • Chore / dependency update / CI change

Checklist

  • I have read the Contributing Guide
  • My code follows the project's code style and conventions
  • I have run npm run typecheck && npm run lint and there are no errors
  • The build passes (npm run build)
  • I have tested my changes locally
  • I have added or updated documentation if needed
  • I have updated translations (locales/) if my changes affect user-facing text
  • I have included screenshots or a screen recording for UI changes

Screenshots / Demo

Notes for Reviewers

I'm not sure what the original intention behind handling the UI padding this way was, but in practice, it is rather unpredictable and an infinite game of chicken and egg. There are too many edge cases to reliably modify the CSS to ensure it renders correctly in our UI. In general, we should keep the email styling as close to the original as possible, and we just provide a canvas for it to be rendered in.

@maxhaomh maxhaomh marked this pull request as ready for review June 18, 2026 13:49
@rathlinus

Copy link
Copy Markdown
Member

maybe making this a setting but completely removing is not a option

@maxhaomh

maxhaomh commented Jun 19, 2026 via email

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Some emails will break CSS of the email-viewer component

2 participants