From 35a8b43ef058134f17a083e991a7001d603ff97a Mon Sep 17 00:00:00 2001 From: Andrei Zhaleznichenka Date: Wed, 2 Oct 2024 18:51:41 +0200 Subject: [PATCH] fix: Fixes property filter count text when token groups are used (#2806) --- .../__tests__/property-filter.filtering-input.test.tsx | 9 +++++++++ src/property-filter/internal.tsx | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/property-filter/__tests__/property-filter.filtering-input.test.tsx b/src/property-filter/__tests__/property-filter.filtering-input.test.tsx index 12c747dfdb..98641b3f51 100644 --- a/src/property-filter/__tests__/property-filter.filtering-input.test.tsx +++ b/src/property-filter/__tests__/property-filter.filtering-input.test.tsx @@ -409,6 +409,15 @@ describe('count text', () => { }); expect(wrapper.findResultsCount()!.getElement()).toHaveTextContent('5 matches'); }); + + test('is visible when there is at least 1 token group', () => { + const { propertyFilterWrapper: wrapper } = renderComponent({ + enableTokenGroups: true, + countText: '5 matches', + query: { operation: 'or', tokens: [], tokenGroups: [{ propertyKey: 'string', value: 'first', operator: ':' }] }, + }); + expect(wrapper.findResultsCount()!.getElement()).toHaveTextContent('5 matches'); + }); }); describe('constraint text', () => { diff --git a/src/property-filter/internal.tsx b/src/property-filter/internal.tsx index 34a389c74c..7ebdb9be88 100644 --- a/src/property-filter/internal.tsx +++ b/src/property-filter/internal.tsx @@ -113,7 +113,6 @@ const PropertyFilterInternal = React.forwardRef( const i18nStrings = usePropertyFilterI18n(rest.i18nStrings); useImperativeHandle(ref, () => ({ focus: () => inputRef.current?.focus() }), []); - const showResults = !!query.tokens?.length && !disabled && !!countText; const [filteringText, setFilteringText] = useState(''); const { internalProperties, internalOptions, internalQuery, internalFreeText } = (() => { @@ -306,6 +305,9 @@ const PropertyFilterInternal = React.forwardRef( const textboxAriaDescribedBy = filteringConstraintText ? joinStrings(rest.ariaDescribedby, constraintTextId) : rest.ariaDescribedby; + + const showResults = !!internalQuery.tokens?.length && !disabled && !!countText; + return (