Meta attribute theme-color uses the default header background color, not the active one

Hi,

When users select another theme in their settings, the meta attribute theme-color is still set to the header_background property of the default theme. It should be set to the value of the active theme instead.

Thanks in advance for looking into this.

(Running Discourse v2.0.5.)

7 Likes

I had this reported yesterday on another forum.

The theme-color tag is used by Chrome on android to style tabs according to the website’s color scheme.

As @gkln said, this seem to have stopped working properly for Discourse sites. Looking at the code, I’m not sure if/how it ever fetched colors from a non-default theme, but it can’t be a coincidence that two separate people have reported it :thinking:. @osama maybe something related to the recent theme changes?

https://github.com/discourse/discourse/blob/master/app/views/layouts/_head.html.erb#L12

7 Likes

The theme-color meta attribute always used the site’s default color scheme instead of the scheme of the current user theme. We’ve had this bug since the inception of user-selectable themes. Here is a fix for it:

https://github.com/discourse/discourse/pull/6384

@gkln thanks for reporting this ancient bug!

11 Likes

@Osama should we also set the user selected color in the https://meta.discourse.org/manifest.webmanifest ?

8 Likes

Yep, looks like Google docs recommend the colors in theme-color meta attr and the manifest file match, so I updated my PR so that the manifest file uses the same colors.

9 Likes