Skip to content

Commit

Permalink
⚡ feat: add prop to the select component for pass the value from a ex…
Browse files Browse the repository at this point in the history
…ternal state
  • Loading branch information
Developer 1 committed Dec 28, 2021
1 parent 023769b commit 216953c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/primitives/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const Select = (
dropdownCloseIcon,
dropdownOpenIcon,
placeholder,
currentValue,
accessibilityLabel,
defaultValue,
size,
Expand Down Expand Up @@ -85,8 +86,10 @@ const Select = (
const selectedItemArray = itemsList.filter(
(item: any) => item.value === value
);

const selectedItem =
selectedItemArray && selectedItemArray.length ? selectedItemArray[0] : null;
currentValue?.value !== undefined
? currentValue : selectedItemArray && selectedItemArray.length ? selectedItemArray[0] : null;

const {
variant,
Expand Down
4 changes: 4 additions & 0 deletions src/components/primitives/Select/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import type { IButtonProps } from '../Button';
import type { IActionsheetContentProps } from '../../composites/Actionsheet/types';

export interface ISelectProps extends IBoxProps {
/**
*The current value from a external state
*/
currentValue?: { value: string, label: string };
/**
* The placeholder that describes the Select.
*/
Expand Down

0 comments on commit 216953c

Please sign in to comment.