Skip to content

Commit

Permalink
[Discover] Fix 0 filters applied state (#5733) (#5742)
Browse files Browse the repository at this point in the history
* [Discover] Fix 0 filters applied state

* Adds changelog
* fixes unit test


---------

Signed-off-by: Ashwin P Chandran <ashwinpc@amazon.com>
(cherry picked from commit f8ee03a)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 03b0fdd commit 25d560c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('DiscoverFieldSearch', () => {
btn = findTestSubject(component, 'toggleFieldFilterButton');
const badge = btn.find('.euiNotificationBadge');
// available filters
expect(badge.text()).toEqual(NUM_FILTERS.toString());
expect(badge.text()).toEqual('0');
// change value of aggregatable select
const aggregatableButtonGroup = findButtonGroup(component, 'aggregatable');
act(() => {
Expand Down Expand Up @@ -114,10 +114,10 @@ describe('DiscoverFieldSearch', () => {
const btn = findTestSubject(component, 'toggleFieldFilterButton');
btn.simulate('click');
const badge = btn.find('.euiNotificationBadge');
expect(badge.text()).toEqual(NUM_FILTERS.toString());
expect(badge.text()).toEqual('0');
const missingSwitch = findTestSubject(component, 'missingSwitch');
missingSwitch.simulate('change', { target: { value: false } });
expect(badge.text()).toEqual(NUM_FILTERS.toString());
expect(badge.text()).toEqual('0');
});

test('change in filters triggers onChange', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export function DiscoverFieldSearch({ onChange, value, types }: Props) {
hasActiveFilters={activeFiltersCount > 0}
aria-label={filterBtnAriaLabel}
data-test-subj="toggleFieldFilterButton"
numFilters={NUM_FILTERS}
numFilters={activeFiltersCount} // {NUM_FILTERS} https://github.com/opensearch-project/oui/issues/1219
onClick={handleFacetButtonClicked}
numActiveFilters={activeFiltersCount}
isSelected={isPopoverOpen}
Expand Down

0 comments on commit 25d560c

Please sign in to comment.