File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff 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 >
Original file line number Diff line number Diff 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 > ;
Original file line number Diff line number Diff 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 */
You can’t perform that action at this time.
0 commit comments