Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export interface SearchInputProps extends Omit<React.HTMLProps<HTMLDivElement>,
appendTo?: HTMLElement | (() => HTMLElement) | 'inline';
/** An accessible label for the search input. */
'aria-label'?: string;
/** Flag to indicate utilities should be displayed. By default if this prop is undefined or false, utilities will only be displayed when the search input has a value. */

areUtilitiesDisplayed?: boolean;
/** Array of attribute values used for dynamically generated advanced search. */
attributes?: string[] | SearchInputSearchAttribute[];
/** Additional classes added to the search input. */
Expand Down Expand Up @@ -152,6 +155,7 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
appendTo,
zIndex = 9999,
name,
areUtilitiesDisplayed,
...props
}: SearchInputProps) => {
const [isSearchMenuOpen, setIsSearchMenuOpen] = React.useState(false);
Expand Down Expand Up @@ -295,7 +299,7 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
onChange={onChangeHandler}
name={name}
/>
{renderUtilities && (
{(renderUtilities || areUtilitiesDisplayed) && (
<TextInputGroupUtilities>
{resultsCount && <Badge isRead>{resultsCount}</Badge>}
{!!onNextClick && !!onPreviousClick && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,11 @@ test('toggleAriaLabel is applied to the expandable toggle', () => {

expect(screen.getByRole('button')).toHaveAccessibleName('Test label');
});

test('Utilities are rendered when areUtilitiesDisplayed is set', () => {
render(
<SearchInput {...props} areUtilitiesDisplayed resetButtonLabel='test-util-display'/>
);
expect(screen.getByLabelText('test-util-display')).toBeVisible();
});