From 28cefb666ac16de08fc80384faedaede1e6600cb Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Fri, 30 Apr 2021 11:31:01 -0400 Subject: [PATCH] FIX: light color scheme picker should default to user selection (#12913) Fixes a bug in user preferences > interface, the light scheme dropdown was defaulting to "Theme Default" even when the user had selected a different scheme. --- .../app/controllers/preferences/interface.js | 4 +--- .../acceptance/user-preferences-interface-test.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/interface.js b/app/assets/javascripts/discourse/app/controllers/preferences/interface.js index eba10ceca2f..6e45ac746f1 100644 --- a/app/assets/javascripts/discourse/app/controllers/preferences/interface.js +++ b/app/assets/javascripts/discourse/app/controllers/preferences/interface.js @@ -237,9 +237,7 @@ export default Controller.extend({ return value; }, get() { - return this.currentSchemeCanBeSelected - ? this.session.userColorSchemeId - : null; + return this.session.userColorSchemeId; }, }), diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js index adbf94e6a67..d2ad0e4ef65 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js @@ -176,6 +176,21 @@ acceptance( ); }); + test("light color scheme defaults to custom scheme selected by user", async function (assert) { + let site = Site.current(); + let session = Session.current(); + session.userColorSchemeId = 2; + site.set("user_color_schemes", [{ id: 2, name: "Cool Breeze" }]); + + await visit("/u/eviltrout/preferences/interface"); + assert.ok(exists(".light-color-scheme"), "has light scheme dropdown"); + assert.equal( + queryAll(".light-color-scheme .selected-name").data("value"), + session.userColorSchemeId, + "user's selected color scheme is selected value in light scheme dropdown" + ); + }); + test("light and dark color scheme pickers", async function (assert) { let site = Site.current(); let session = Session.current();