Skip to content

Background colour on social links in emails not working#2722

Open
Agboolafeyikemi wants to merge 1 commit into
codebar:masterfrom
Agboolafeyikemi:feature/email-social-links-background
Open

Background colour on social links in emails not working#2722
Agboolafeyikemi wants to merge 1 commit into
codebar:masterfrom
Agboolafeyikemi:feature/email-social-links-background

Conversation

@Agboolafeyikemi

@Agboolafeyikemi Agboolafeyikemi commented Jul 24, 2026

Copy link
Copy Markdown

Description

Inlines the background-color on each social link in shared_mailers/_social.html.haml, so the buttons in email footers render with their colours regardless of which version of email.css gets inlined by premailer.

Closes #2634

Root cause

Production emails have been inlining a stale copy of /assets/email.css — the undigested URL that was hard-coded in the mailer header until #2715. codebar.io still serves a pre-November-2024 version of that file (verified byte-for-byte against git history), cached with Cache-Control: public, max-age=31556952. That version only has background rules for a.fb and a.tw, so only the Facebook button gets a colour with today's markup exactly what the screenshots on #2634 and #2437 show. This is also why the fix in #2437 didn't take effect: it changed the source file, but emails kept inlining the stale cached copy.

Full write-up in this comment on the issue.

Why inline styles

Email clients only reliably render inline styles, and critical visual styles in emails shouldn't depend on a separately fetched stylesheet. With the colours inline in the template, the buttons are correct even if email.css resolution fails or serves stale content. The CSS rules remain as a fallback.

How this was tested

  • Reproduced the production bug locally: rendered the mailer preview against the actual stale CSS downloaded from codebar.io, only Facebook got a background, matching the issue screenshots.
  • Re-rendered with this fix against the same stale CSS, all five buttons get their colours.
  • Added a mailer spec asserting the rendered template carries an inline background-color for each social link (it asserts pre-premailer output, so it fails if the colours ever move back to being stylesheet-only).
  • bundle exec rspec spec/mailers/workshop_invitation_mailer_spec.rb 14 examples, 0 failures. RuboCop clean on the changed lines.

Inline the background colour on each social link in the shared mailer
partial instead of relying on email.css. Email clients only reliably
render inline styles, and production emails have been inlining a stale
cached copy of /assets/email.css that predates the current social
links, which left every button except Facebook with invisible white
text on no background.

With the colours inlined in the template, the buttons render correctly
regardless of which version of the stylesheet premailer resolves.

Closes codebar#2634.
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.

Background colour on social links in emails not working

1 participant