Skip to content

Commit

Permalink
CC-6624: Update FilterBar results text on search (#74)
Browse files Browse the repository at this point in the history
* update filter bar filter status text to include searched text

* update test assertions

* add changeset (patch)

* fix linter error whitespace
  • Loading branch information
ellacai committed Oct 5, 2023
1 parent 573dac5 commit f4df22e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/ten-mugs-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hashicorp/consul-ui-toolkit': patch
---

Update FilterBar results text on search to include searched text
6 changes: 4 additions & 2 deletions documentation/tests/integration/components/filter-bar-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,9 @@ module('Integration | Component | cut/filter-bar', function (hooks) {
},
});

assert.dom('[data-test-filter-bar-results]').hasText('Searching');
assert
.dom('[data-test-filter-bar-results]')
.hasText('Showing results for bloom');
});

test('shows searching text with the name when there are no filters applied and search is applied no count is passed in and the name is set', async function (assert) {
Expand All @@ -384,7 +386,7 @@ module('Integration | Component | cut/filter-bar', function (hooks) {

assert
.dom('[data-test-filter-bar-results]')
.hasText('Searching Service Instances');
.hasText('Showing results for bloom');
});

test('shows a result count with a default text for the name if you pass in a count but no name', async function (assert) {
Expand Down
4 changes: 2 additions & 2 deletions toolkit/src/components/cut/filter-bar/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
}}
{{else if this.isFiltering}}
Filters applied:
{{else if this.isSearching}}
Searching{{if @name (concat ' ' (pluralize @name))}}
{{else if (and this.isSearching this.appliedSearch)}}
Showing results for {{this.appliedSearch}}
{{else}}
Showing all
{{if @name (pluralize @name) 'results'}}
Expand Down
4 changes: 4 additions & 0 deletions toolkit/src/components/cut/filter-bar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ export default class FilterBarComponent extends Component<FilterBarSignature> {
return !!this.args.config?.search?.value;
}

get appliedSearch(): string {
return this.args.config?.search?.value || '';
}

isChecked(localConfig: FilterConfig, filter: string, value: unknown) {
if (Array.isArray(localConfig?.filters?.[filter])) {
return !!(localConfig?.filters?.[filter] as Filter[]).find(
Expand Down

1 comment on commit f4df22e

@vercel
Copy link

@vercel vercel bot commented on f4df22e Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.