UX: Better visibility for context search (#14599)

UX: Better visibility for context search (#14599)

diff --git a/app/assets/javascripts/discourse/app/widgets/search-menu-results.js b/app/assets/javascripts/discourse/app/widgets/search-menu-results.js
index bae2e83..364fee7 100644
--- a/app/assets/javascripts/discourse/app/widgets/search-menu-results.js
+++ b/app/assets/javascripts/discourse/app/widgets/search-menu-results.js
@@ -480,7 +480,8 @@ createWidget("search-menu-initial-options", {
     const ctx = service.get("searchContext");
 
     const content = [];
-    if (attrs.term) {
+
+    if (attrs.term || ctx) {
       if (ctx) {
         const term = attrs.term ? `${attrs.term} ` : "";
 
@@ -549,8 +550,9 @@ createWidget("search-menu-initial-options", {
         }
       }
 
-      const rowOptions = { withLabel: true };
-      content.push(this.defaultRow(attrs.term, rowOptions));
+      if (attrs.term) {
+        content.push(this.defaultRow(attrs.term, { withLabel: true }));
+      }
       return content;
     }
 
@@ -601,6 +603,7 @@ createWidget("search-menu-assistant-item", {
           category: attrs.category,
           allowUncategorized: true,
           recursive: true,
+          link: false,
         })
       );
     } else if (attrs.tag) {
diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-test.js
index 0478e65..9579165 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/search-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/search-test.js
@@ -117,6 +117,13 @@ acceptance("Search - Anonymous", function (needs) {
 
     await visit("/tag/important");
     await click("#search-button");
+
+    assert.equal(
+      query(firstResult).textContent.trim(),
+      `${I18n.t("search.in")} test`,
+      "contenxtual tag search is first available option with no term"
+    );
+
     await fillIn("#search-term", "smth");
 
     assert.equal(
@@ -134,6 +141,11 @@ acceptance("Search - Anonymous", function (needs) {
       "category-scoped search is first available option"
     );
 
+    assert.ok(
+      exists(`${firstResult} span.badge-wrapper`),
+      "category badge is a span (i.e. not a link)"
+    );
+
     await visit("/t/internationalization-localization/280");
     await click("#search-button");
 
@@ -159,6 +171,16 @@ acceptance("Search - Anonymous", function (needs) {
     await visit("/t/internationalization-localization/280/1");
 
     await click("#search-button");
+
+    const firstResult =
+      ".search-menu .results .search-menu-assistant-item:first-child";
+
+    assert.equal(
+      query(firstResult).textContent.trim(),
+      I18n.t("search.in_this_topic"),
+      "contenxtual topic search is first available option"
+    );
+
     await fillIn("#search-term", "a proper");
     await focus("input#search-term");
     await triggerKeyEvent(".search-menu", "keydown", 40);

GitHub sha: 0616a5ac7cfe78cf1986948eb6ba95b85a4c4f5c

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