Skip to content

Commit acf3d73

Browse files
UX: Add category badges to category filter tip results (#34078)
This PR adds category badges to be shown in the filter tips menu. --------- Co-authored-by: Martin Brennan <martin@discourse.org>
1 parent 025f5ba commit acf3d73

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

app/assets/javascripts/discourse/app/components/discovery/filter-navigation-menu.gjs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { TrackedObject } from "@ember-compat/tracked-built-ins";
1010
import { eq } from "truth-helpers";
1111
import DButton from "discourse/components/d-button";
1212
import DropdownMenu from "discourse/components/dropdown-menu";
13+
import categoryBadge from "discourse/helpers/category-badge";
1314
import concatClass from "discourse/helpers/concat-class";
1415
import icon from "discourse/helpers/d-icon";
1516
import withEventValue from "discourse/helpers/with-event-value";
@@ -32,12 +33,17 @@ const FilterNavigationMenuList = <template>
3233
}}
3334
@action={{fn @data.selectItem item}}
3435
>
35-
<span class="filter-navigation__tip-name">
36-
{{item.name}}
37-
</span>
38-
{{#if item.description}}
39-
<span class="filter-navigation__tip-description">—
40-
{{item.description}}</span>
36+
{{#if item.category}}
37+
{{categoryBadge item.category allowUncategorized=true}}
38+
{{else}}
39+
<span class="filter-navigation__tip-name">
40+
{{item.name}}
41+
</span>
42+
43+
{{#if item.description}}
44+
<span class="filter-navigation__tip-description">—
45+
{{item.description}}</span>
46+
{{/if}}
4147
{{/if}}
4248
</DButton>
4349
</dropdown.item>

app/assets/javascripts/discourse/app/lib/filter-suggestions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export default class FilterSuggestions {
106106
description: `${category.name}`,
107107
isSuggestion: true,
108108
term: category.slug,
109+
category,
109110
}));
110111
}
111112

app/assets/javascripts/discourse/tests/integration/components/discovery/filter-navigation-menu-test.gjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,14 @@ module(
222222
await triggerEvent("#topic-query-filter-input", "focus");
223223
await fillIn("#topic-query-filter-input", "cat");
224224

225+
assert
226+
.dom(".filter-navigation__tip-button")
227+
.exists("category search results shown");
228+
229+
assert
230+
.dom(".filter-navigation__tip-button")
231+
.exists(".badge-category__wrapper", "category badge HTML shown");
232+
225233
await triggerKeyEvent(
226234
"#topic-query-filter-input",
227235
"keydown",

0 commit comments

Comments
 (0)