FIX: set overridden param for customize site text query only when checkbox value changes

FIX: set overridden param for customize site text query only when checkbox value changes

From a2bff038e8f3a9b17aa7f4df5bd3ee3b368128b2 Mon Sep 17 00:00:00 2001
From: Maja Komel <maja.komel@gmail.com>
Date: Mon, 26 Nov 2018 18:47:11 +0100
Subject: [PATCH] FIX: set overridden param for customize site text query only
 when checkbox value changes


diff --git a/app/assets/javascripts/admin/controllers/admin-site-text-index.js.es6 b/app/assets/javascripts/admin/controllers/admin-site-text-index.js.es6
index 6aad6a9..a62c740 100644
--- a/app/assets/javascripts/admin/controllers/admin-site-text-index.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-site-text-index.js.es6
@@ -25,8 +25,7 @@ export default Ember.Controller.extend({
     },
 
     search(overridden) {
-      this.set("overridden", overridden);
-
+      if (typeof overridden === "boolean") this.set("overridden", overridden);
       const q = this.get("q");
       if (q !== lastSearch || overridden !== lastOverridden) {
         this.set("searching", true);
diff --git a/test/javascripts/acceptance/admin-site-text-test.js.es6 b/test/javascripts/acceptance/admin-site-text-test.js.es6
index 766dd1d..d37f486 100644
--- a/test/javascripts/acceptance/admin-site-text-test.js.es6
+++ b/test/javascripts/acceptance/admin-site-text-test.js.es6
@@ -7,12 +7,17 @@ QUnit.test("search for a key", async assert => {
 
   await fillIn(".site-text-search", "Test");
 
+  assert.equal(currentURL(), "/admin/customize/site_texts?q=Test");
   assert.ok(exists(".site-text"));
   assert.ok(exists(".site-text:not(.overridden)"));
   assert.ok(exists(".site-text.overridden"));
 
   // Only show overridden
   await click(".extra-options input");
+  assert.equal(
+    currentURL(),
+    "/admin/customize/site_texts?overridden=true&q=Test"
+  );
 
   assert.ok(!exists(".site-text:not(.overridden)"));
   assert.ok(exists(".site-text.overridden"));

GitHub

1 Like