A platform for community discussion. Free, open, simple.
Meta topic: https://meta.discourse.org/t/meta-theme-color-is-not-respecting-current-color-scheme/239815 (#18832)
kaden-stytch29a32f95664e
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rbindex d2078d15eb8..96d3c11a659 100644--- a/app/helpers/application_helper.rb+++ b/app/helpers/application_helper.rb@@ -626,13 +626,16 @@ module ApplicationHelperenddef discourse_theme_color_meta_tags- result = +<<~HTML- <meta name="theme-color" media="all" content="##{ColorScheme.hex_for_name('header_background', scheme_id)}">- HTML+ result = +""if dark_scheme_id != -1result << <<~HTML+ <meta name="theme-color" media="(prefers-color-scheme: light)" content="##{ColorScheme.hex_for_name('header_background', scheme_id)}"><meta name="theme-color" media="(prefers-color-scheme: dark)" content="##{ColorScheme.hex_for_name('header_background', dark_scheme_id)}">HTML+ else+ result << <<~HTML+ <meta name="theme-color" media="all" content="##{ColorScheme.hex_for_name('header_background', scheme_id)}">+ HTMLendresult.html_safeenddiff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rbindex 8b3ae785ccc..e00f88c5eaf 100644--- a/spec/helpers/application_helper_spec.rb+++ b/spec/helpers/application_helper_spec.rb@@ -753,9 +753,9 @@ RSpec.describe ApplicationHelper dohelper.request.cookies["dark_scheme_id"] = dark.idend- it "renders theme-color meta for the light scheme with media=all and another one for the dark scheme with media=(prefers-color-scheme: dark)" do+ it "renders theme-color meta for the light scheme with media=(prefers-color-scheme: light) and another one for the dark scheme with media=(prefers-color-scheme: dark)" doexpect(helper.discourse_theme_color_meta_tags).to eq(<<~HTML)- <meta name="theme-color" media="all" content="#abcdef">+ <meta name="theme-color" media="(prefers-color-scheme: light)" content="#abcdef"><meta name="theme-color" media="(prefers-color-scheme: dark)" content="#defabc">HTMLend