Skip to content

Commit 5a4b6ff

Browse files
authored
Merge pull request #6 from imdevan/767-suja-pr
2 parents 4130e88 + 05afec6 commit 5a4b6ff

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

examples/App.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ export default function App(): JSX.Element {
7777
description="This is the default dropdown picker - with search"
7878
dropdownProps={{searchable: true}}
7979
/>
80+
81+
<DropDownPickerExample
82+
title="Multiple Search Example"
83+
description="This is the default dropdown picker - with search"
84+
multiple
85+
dropdownProps={{searchable: true}}
86+
/>
87+
88+
<DropDownPickerExample
89+
title="Multiple Search Clear on Select Example"
90+
description="This is the default dropdown picker - with search"
91+
multiple
92+
dropdownProps={{searchable: true, clearSearchFieldOnSelect: true, mode: "BADGE"}}
93+
/>
8094
</View>
8195
</View>
8296
</View>

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ declare module 'react-native-dropdown-picker' {
198198
customItemContainerStyle?: StyleProp<ViewStyle>;
199199
customItemLabelStyle?: StyleProp<TextStyle>;
200200
customItemValueDelimiter?: string;
201+
clearSearchFieldOnSelect?: boolean;
201202
disableBorderRadius?: boolean;
202203
disabledItemContainerStyle?: StyleProp<ViewStyle>;
203204
disabledItemLabelStyle?: StyleProp<TextStyle>;

src/components/Picker.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ function Picker({
8484
customItemContainerStyle = {},
8585
customItemLabelStyle = {},
8686
customItemValueDelimiter = '-',
87+
clearSearchFieldOnSelect = false,
8788
disableBorderRadius = true,
8889
disabled = false,
8990
disabledItemContainerStyle = {},
@@ -349,6 +350,19 @@ function Picker({
349350
if (mode === MODE.SIMPLE) badgeFlatListRef.current = null;
350351
}, [mode]);
351352

353+
/**
354+
* clear search field on item select.
355+
*/
356+
useEffect(() => {
357+
if (
358+
clearSearchFieldOnSelect == true &&
359+
multiple == true &&
360+
searchText.length > 0
361+
) {
362+
setSearchText('');
363+
}
364+
}, [value]);
365+
352366
/**
353367
* onPressClose.
354368
*/

0 commit comments

Comments
 (0)