Skip to content

Commit 444fde7

Browse files
committed
add clear callback
1 parent bb543d0 commit 444fde7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/react-core/src/components/DualListSelector/DualListSelectorPane.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ export interface DualListSelectorPaneProps {
5757
onSearch?: (event: React.ChangeEvent<HTMLInputElement>) => void;
5858
/** @hide A callback for when the search input value for changes. To be used when isSearchable is true. */
5959
onSearchInputChanged?: (value: string, event: React.FormEvent<HTMLInputElement>) => void;
60+
/** @hide Callback for search input clear button */
61+
onSearchInputClear?: (event: React.SyntheticEvent<HTMLButtonElement>) => void;
6062
/** @hide Filter function for custom filtering based on search string. To be used when isSearchable is true. */
6163
filterOption?: (option: React.ReactNode, input: string) => boolean;
6264
/** @hide Accessible label for the search input. To be used when isSearchable is true. */
@@ -81,6 +83,7 @@ export const DualListSelectorPane: React.FunctionComponent<DualListSelectorPaneP
8183
searchInputAriaLabel = '',
8284
onFilterUpdate,
8385
onSearchInputChanged,
86+
onSearchInputClear,
8487
filterOption,
8588
id = getUniqueId('dual-list-selector-pane'),
8689
isDisabled = false,
@@ -161,6 +164,9 @@ export const DualListSelectorPane: React.FunctionComponent<DualListSelectorPaneP
161164
) : (
162165
<SearchInput
163166
onChange={isDisabled ? undefined : onChange}
167+
onClear={
168+
onSearchInputClear ? onSearchInputClear : e => onChange('', e as React.FormEvent<HTMLInputElement>)
169+
}
164170
isDisabled={isDisabled}
165171
aria-label={searchInputAriaLabel}
166172
type="search"

0 commit comments

Comments
 (0)