FIX: Toggle search menu when click the same button (#13781)

FIX: Toggle search menu when click the same button (#13781)

diff --git a/app/assets/javascripts/discourse/app/widgets/search-menu.js b/app/assets/javascripts/discourse/app/widgets/search-menu.js
index 6514e9a..2ea06cd 100644
--- a/app/assets/javascripts/discourse/app/widgets/search-menu.js
+++ b/app/assets/javascripts/discourse/app/widgets/search-menu.js
@@ -286,7 +286,7 @@ export default createWidget("search-menu", {
     });
   },
 
-  mouseDownOutside() {
+  clickOutside() {
     this.sendWidgetAction("toggleSearchMenu");
   },
 
diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-test.js
index a61257e..64224c8 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/search-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/search-test.js
@@ -52,6 +52,22 @@ acceptance("Search - Anonymous", function (needs) {
     );
   });
 
+  test("search button toggles search menu", async function (assert) {
+    await visit("/");
+
+    await click("#search-button");
+    assert.ok(exists(".search-menu"));
+
+    await click(".d-header"); // click outside
+    assert.ok(!exists(".search-menu"));
+
+    await click("#search-button");
+    assert.ok(exists(".search-menu"));
+
+    await click("#search-button"); // toggle same button
+    assert.ok(!exists(".search-menu"));
+  });
+
   test("search for a tag", async function (assert) {
     await visit("/");
 

GitHub sha: e3144fc0c72a0ffd4bb6e5fb43e477ca541d2234

This commit appears in #13781 which was approved by eviltrout. It was merged by pmusaraj.

This commit has been mentioned on Discourse Meta. There might be relevant details there: