Skip to content

Commit

Permalink
fix: Fixes property filter count text when token groups are used (#2806)
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-kot authored Oct 2, 2024
1 parent 597c7c5 commit 35a8b43
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
4 changes: 3 additions & 1 deletion src/property-filter/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>('');

const { internalProperties, internalOptions, internalQuery, internalFreeText } = (() => {
Expand Down Expand Up @@ -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 (
<div {...baseProps} className={clsx(baseProps.className, styles.root)} ref={mergedRef}>
<div className={clsx(styles['search-field'], analyticsSelectors['search-field'])}>
Expand Down

0 comments on commit 35a8b43

Please sign in to comment.