From 0a3cc22cec2572c4e63667f460438a145d8c9430 Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Mon, 20 Apr 2020 08:31:43 -0500 Subject: [PATCH] FIX: Wizard was creating duplicate Light theme if Light was selected (#9464) --- lib/wizard/builder.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/wizard/builder.rb b/lib/wizard/builder.rb index 40318d8aa94..5372d3428b4 100644 --- a/lib/wizard/builder.rb +++ b/lib/wizard/builder.rb @@ -181,11 +181,16 @@ class Wizard next unless scheme_name.present? && ColorScheme.is_base?(scheme_name) name = I18n.t("color_schemes.#{scheme_name.downcase.gsub(' ', '_')}_theme_name") - theme = nil scheme = ColorScheme.find_by(base_scheme_id: scheme_name, via_wizard: true) + is_light_theme = (scheme_name == ColorScheme::LIGHT_THEME_ID) scheme ||= ColorScheme.create_from_base(name: name, via_wizard: true, base_scheme_id: scheme_name) + themes = Theme.where(color_scheme_id: scheme.id).order(:id).to_a + if is_light_theme + themes = (themes || []).concat(Theme.where(color_scheme_id: nil).order(:id).to_a) + themes.sort_by(&:id) + end theme = themes.find(&:default?) theme ||= themes.first