diff --git a/src/components/Dropdown/index.tsx b/src/components/Dropdown/index.tsx index eef6ed8..3c4dec1 100644 --- a/src/components/Dropdown/index.tsx +++ b/src/components/Dropdown/index.tsx @@ -92,6 +92,7 @@ const DropdownComponent: ( closeModalWhenSelectedItem = true, excludeItems = [], excludeSearchItems = [], + selectedVal } = props; const ref = useRef(null); @@ -424,7 +425,8 @@ const DropdownComponent: ( > {renderLeftIcon?.(visible)} - ( {isSelected !== null ? _.get(currentValue, labelField) : placeholder} - + } {renderRightIcon ? ( renderRightIcon(visible) ) : ( @@ -453,6 +455,13 @@ const DropdownComponent: ( ); }; + const __renderSelectedVal = () => { + if (selectedVal) { + return selectedVal; + } + return null; + }; + const _renderItem = useCallback( ({ item, index }: { item: any; index: number }) => { const isSelected = currentValue && _.get(currentValue, valueField); diff --git a/src/components/Dropdown/model.ts b/src/components/Dropdown/model.ts index 0e029b2..2f1e57c 100644 --- a/src/components/Dropdown/model.ts +++ b/src/components/Dropdown/model.ts @@ -57,6 +57,7 @@ export interface DropdownProps { closeModalWhenSelectedItem?: boolean; excludeItems?: T[]; excludeSearchItems?: T[]; + selectedVal?: JSX.Element | null | undefined; onChange: (item: T) => void; renderLeftIcon?: (visible?: boolean) => JSX.Element | null | undefined; renderRightIcon?: (visible?: boolean) => JSX.Element | null | undefined;