Wizard: Use SearchInput component for packages

As a small simplification and also to make the UX more consistent, let's
use a SearchInput widget over the custom InputGroup structure.
The only aspect lost in the process is the `validation` property that
doesn't exist in the SearchInput widget. It however only affects the CSS
styling of the searchbox and renders the 'error' state when there's only
a single character in the box. This may not even be desirable, given
that it's not really an error and that we show a note right below the
input box about this anyway.

This means the search boxes will also be consistent between the
repository and package search pages.
Fixes #3133
This commit is contained in:
Simon Steinbeiss 2025-04-23 15:47:15 +02:00 committed by Klara Simickova
parent 0238c04dfe
commit c7dd274298

View file

@ -15,19 +15,16 @@ import {
EmptyStateIcon,
EmptyStateVariant,
Icon,
InputGroup,
InputGroupItem,
InputGroupText,
Pagination,
PaginationVariant,
Popover,
SearchInput,
Spinner,
Stack,
Tab,
Tabs,
TabTitleText,
Text,
TextInput,
ToggleGroup,
ToggleGroupItem,
Toolbar,
@ -40,7 +37,6 @@ import {
HelpIcon,
OptimizeIcon,
SearchIcon,
TimesIcon,
} from '@patternfly/react-icons';
import {
ExpandableRowContent,
@ -1248,39 +1244,16 @@ const Packages = () => {
<Stack>
<ToolbarContent>
<ToolbarItem variant="search-filter">
<InputGroup>
<InputGroupItem isFill>
<InputGroupText id="search-icon">
<SearchIcon />
</InputGroupText>
<TextInput
data-ouia-component-id="packages-search-input"
type="text"
validated={
debouncedSearchTermLengthOf1 &&
!debouncedSearchTermIsGroup
? 'error'
: 'default'
}
placeholder="Type to search"
aria-label="Search packages"
data-testid="packages-search-input"
value={searchTerm}
onChange={handleSearch}
/>
</InputGroupItem>
{searchTerm && (
<InputGroupItem>
<Button
variant="control"
aria-label="clear-package-search"
onClick={handleClear}
icon={<TimesIcon />}
ouiaId="clear-package-search-button"
/>
</InputGroupItem>
)}
</InputGroup>
<SearchInput
data-ouia-component-id="packages-search-input"
type="text"
placeholder="Type to search"
aria-label="Search packages"
data-testid="packages-search-input"
value={searchTerm}
onChange={handleSearch}
onClear={() => handleClear()}
/>
</ToolbarItem>
<ToolbarItem>
<ToggleGroup>