Skip to content

Commit

Permalink
feat: add props closeModalWhenSelectedItem
Browse files Browse the repository at this point in the history
  • Loading branch information
hoaphantn7604 committed May 3, 2024
1 parent 7f3cd78 commit a3c771b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions example/src/dropdown/Dropdown2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const DropdownComponent = () => {
placeholder="Dropdown 2"
searchPlaceholder="Search..."
value={value}
closeModalWhenSelectedItem={false}
onChange={(item) => {
setValue(item.value);
}}
Expand Down
6 changes: 5 additions & 1 deletion src/components/Dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const DropdownComponent: <T>(
accessibilityLabel,
itemAccessibilityLabelField,
mode = 'default',
closeModalWhenSelectedItem = true,
} = props;

const ref = useRef<View>(null);
Expand Down Expand Up @@ -353,7 +354,9 @@ const DropdownComponent: <T>(
onSearch('');
setCurrentValue(item);
onChange(item);
eventClose();
if (closeModalWhenSelectedItem) {
eventClose();
}
},
[
confirmSelectItem,
Expand All @@ -362,6 +365,7 @@ const DropdownComponent: <T>(
onChangeText,
onConfirmSelectItem,
onSearch,
closeModalWhenSelectedItem,
]
);

Expand Down
1 change: 1 addition & 0 deletions src/components/Dropdown/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface DropdownProps<T> {
itemAccessibilityLabelField?: string;
inverted?: boolean;
mode?: 'default' | 'modal' | 'auto';
closeModalWhenSelectedItem?: boolean;
onChange: (item: T) => void;
renderLeftIcon?: (visible?: boolean) => JSX.Element | null | undefined;
renderRightIcon?: (visible?: boolean) => JSX.Element | null | undefined;
Expand Down

0 comments on commit a3c771b

Please sign in to comment.