From c68b7bb85cf2149b425667decfea3c3e405b63ef Mon Sep 17 00:00:00 2001 From: Ashwin P Chandran Date: Thu, 25 Jan 2024 01:21:06 +0000 Subject: [PATCH 1/3] [Discover] Fix 0 filters applied state Signed-off-by: Ashwin P Chandran --- .../application/components/sidebar/discover_field_search.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field_search.tsx b/src/plugins/discover/public/application/components/sidebar/discover_field_search.tsx index 8d90e0ae1099..ebf4e021101d 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field_search.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_field_search.tsx @@ -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/OpenSearch-Dashboards/issues/5650 onClick={handleFacetButtonClicked} numActiveFilters={activeFiltersCount} isSelected={isPopoverOpen} From 804529c7db18ee0af8202f779b07c32501a76f6d Mon Sep 17 00:00:00 2001 From: Ashwin P Chandran Date: Thu, 25 Jan 2024 02:36:27 +0000 Subject: [PATCH 2/3] Adds changelog Signed-off-by: Ashwin P Chandran --- CHANGELOG.md | 1 + .../application/components/sidebar/discover_field_search.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fac5e39539e6..78090e46fae7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - [BUG][Data] Fix empty suggestion history when querying in search bar [#5349](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5349) - [BUG][Discover] Fix what is displayed in `selected fields` when removing columns from canvas [#5537](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5537) - [BUG][Discover] Fix advanced setting `discover:modifyColumnsOnSwitch` ([#5508](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5508)) +- [BUG][Discover] Show 0 filters when there are no active filters ([#5508](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5508)) - [Discover] Fix missing index pattern field from breaking Discover [#5626](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5626) - [BUG] Remove duplicate sample data as id 90943e30-9a47-11e8-b64d-95841ca0b247 ([5668](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5668)) - [BUG][Multiple Datasource] Fix datasource testing connection unexpectedly passed with wrong endpoint [#5663](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5663) diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field_search.tsx b/src/plugins/discover/public/application/components/sidebar/discover_field_search.tsx index ebf4e021101d..4b50c44b3235 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field_search.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_field_search.tsx @@ -273,7 +273,7 @@ export function DiscoverFieldSearch({ onChange, value, types }: Props) { hasActiveFilters={activeFiltersCount > 0} aria-label={filterBtnAriaLabel} data-test-subj="toggleFieldFilterButton" - numFilters={activeFiltersCount} // {NUM_FILTERS} https://github.com/opensearch-project/OpenSearch-Dashboards/issues/5650 + numFilters={activeFiltersCount} // {NUM_FILTERS} https://github.com/opensearch-project/oui/issues/1219 onClick={handleFacetButtonClicked} numActiveFilters={activeFiltersCount} isSelected={isPopoverOpen} From 77a86ea3685e9b866272f2ddec99b4b23e35798a Mon Sep 17 00:00:00 2001 From: Ashwin P Chandran Date: Thu, 25 Jan 2024 10:23:06 +0000 Subject: [PATCH 3/3] fixes unit test Signed-off-by: Ashwin P Chandran --- .../components/sidebar/discover_field_search.test.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field_search.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_field_search.test.tsx index bcf72ae57326..807b8b98b3f4 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field_search.test.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_field_search.test.tsx @@ -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(() => { @@ -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', () => {