diff --git a/lib/stylesheet/importer.rb b/lib/stylesheet/importer.rb index 47f8e709a5d..bf2c1186548 100644 --- a/lib/stylesheet/importer.rb +++ b/lib/stylesheet/importer.rb @@ -135,8 +135,11 @@ module Stylesheet rescue ColorScheme.base_colors end + elsif (@theme_id && theme.color_scheme) + colors = theme.color_scheme.resolved_colors else - colors = (@theme_id && theme.color_scheme) ? theme.color_scheme.resolved_colors : ColorScheme.base_colors + colors = Theme.find_by_id(SiteSetting.default_theme_id)&.color_scheme&.resolved_colors || + ColorScheme.base_colors end colors.each do |n, hex| diff --git a/spec/components/stylesheet/manager_spec.rb b/spec/components/stylesheet/manager_spec.rb index 97ab426f617..53079526d89 100644 --- a/spec/components/stylesheet/manager_spec.rb +++ b/spec/components/stylesheet/manager_spec.rb @@ -415,6 +415,24 @@ describe Stylesheet::Manager do expect { stylesheet.compile }.not_to raise_error end + + it "child theme SCSS includes the default theme's color scheme variables" do + SiteSetting.default_theme_id = theme.id + custom_scheme = ColorScheme.create_from_base(name: "Neutral", base_scheme_id: "Neutral") + ColorSchemeRevisor.revise(custom_scheme, colors: [{ name: "primary", hex: "CC0000" }]) + theme.color_scheme_id = custom_scheme.id + theme.save! + + scss = "body{ border: 2px solid $primary;}" + child.set_field(target: :common, name: "scss", value: scss) + child.save! + + child_theme_manager = Stylesheet::Manager.new(:desktop_theme, child.id) + child_theme_manager.compile(force: true) + + child_css = File.read(child_theme_manager.stylesheet_fullpath) + expect(child_css).to include("body{border:2px solid #c00}") + end end context 'encoded slugs' do