Skip to content

A platform for community discussion. Free, open, simple.

UX: Add category badges to category filter tip results (#34078)

Jordan Vidrineacf3d73e6371
diff --git a/app/assets/javascripts/discourse/app/components/discovery/filter-navigation-menu.gjs b/app/assets/javascripts/discourse/app/components/discovery/filter-navigation-menu.gjs
index 0e3a1035da5..babbcc06486 100644
--- a/app/assets/javascripts/discourse/app/components/discovery/filter-navigation-menu.gjs
+++ b/app/assets/javascripts/discourse/app/components/discovery/filter-navigation-menu.gjs
@@ -10,6 +10,7 @@ import { TrackedObject } from "@ember-compat/tracked-built-ins";
import { eq } from "truth-helpers";
import DButton from "discourse/components/d-button";
import DropdownMenu from "discourse/components/dropdown-menu";
+import categoryBadge from "discourse/helpers/category-badge";
import concatClass from "discourse/helpers/concat-class";
import icon from "discourse/helpers/d-icon";
import withEventValue from "discourse/helpers/with-event-value";
@@ -32,12 +33,17 @@ const FilterNavigationMenuList = <template>
}}
@action={{fn @data.selectItem item}}
>
- <span class="filter-navigation__tip-name">
- {{item.name}}
- </span>
- {{#if item.description}}
- <span class="filter-navigation__tip-description">—
- {{item.description}}</span>
+ {{#if item.category}}
+ {{categoryBadge item.category allowUncategorized=true}}
+ {{else}}
+ <span class="filter-navigation__tip-name">
+ {{item.name}}
+ </span>
+
+ {{#if item.description}}
+ <span class="filter-navigation__tip-description">—
+ {{item.description}}</span>
+ {{/if}}
{{/if}}
</DButton>
</dropdown.item>
diff --git a/app/assets/javascripts/discourse/app/lib/filter-suggestions.js b/app/assets/javascripts/discourse/app/lib/filter-suggestions.js
index 8587d293dae..3e096d82599 100644
--- a/app/assets/javascripts/discourse/app/lib/filter-suggestions.js
+++ b/app/assets/javascripts/discourse/app/lib/filter-suggestions.js
@@ -106,6 +106,7 @@ export default class FilterSuggestions {
description: `${category.name}`,
isSuggestion: true,
term: category.slug,
+ category,
}));
}
diff --git a/app/assets/javascripts/discourse/tests/integration/components/discovery/filter-navigation-menu-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/discovery/filter-navigation-menu-test.gjs
index f5521a025ac..0a1255acfd2 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/discovery/filter-navigation-menu-test.gjs
+++ b/app/assets/javascripts/discourse/tests/integration/components/discovery/filter-navigation-menu-test.gjs
@@ -222,6 +222,14 @@ module(
await triggerEvent("#topic-query-filter-input", "focus");
await fillIn("#topic-query-filter-input", "cat");
+ assert
+ .dom(".filter-navigation__tip-button")
+ .exists("category search results shown");
+
+ assert
+ .dom(".filter-navigation__tip-button")
+ .exists(".badge-category__wrapper", "category badge HTML shown");
+
await triggerKeyEvent(
"#topic-query-filter-input",
"keydown",