Skip to content

Commit

Permalink
Update to use config search value (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
WenInCode committed Sep 5, 2023
1 parent d4369d4 commit bbff69e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/olive-ducks-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hashicorp/consul-ui-toolkit': patch
---

Update `<Cut::FilterBar::Search />` to use search as a value on the search input
16 changes: 16 additions & 0 deletions documentation/tests/integration/components/filter-bar-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,4 +410,20 @@ module('Integration | Component | cut/filter-bar', function (hooks) {
'Search is updated with the new search value'
);
});

test('if search is set by the config it should prepulate the input', async function (assert) {
await setupTest.call(this, {
config: {
search: { value: 'orange' },
},
});

assert.dom('[data-test-search]').hasValue('orange');
});

test('if search is not set by the config it should not prepulate the input', async function (assert) {
await setupTest.call(this);

assert.dom('[data-test-search]').hasNoValue();
});
});
2 changes: 1 addition & 1 deletion toolkit/src/components/cut/filter-bar/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<div class='cut-filter-bar' aria-label='Filter bar'>
<div class='cut-filter-bar-filters'>
<div class='cut-filter-bar-filtergroup'>

{{yield
(hash
FilterGroup=(component
Expand Down Expand Up @@ -42,6 +41,7 @@
)
Search=(component
'cut/filter-bar/search'
search=@config.search.value
onSearchInput=this.onSearchInput
onSearchKeyup=this.onSearchKeyup
)
Expand Down
2 changes: 2 additions & 0 deletions toolkit/src/components/cut/filter-bar/search.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{{#let @group as |SG|}}
<SG.TextInput
@type='search'
@value={{@search}}
placeholder='Search'
aria-label='Search'
{{on 'keyup' @onSearchKeyup}}
Expand All @@ -16,6 +17,7 @@
{{else}}
<Hds::Form::TextInput::Base
@type='search'
@value={{@search}}
placeholder='Search'
aria-label='Search'
class='cut-filter-bar-search'
Expand Down

1 comment on commit bbff69e

@vercel
Copy link

@vercel vercel bot commented on bbff69e Sep 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.