@@ -66,6 +66,7 @@ export type DropdownProps = CommonComponentProps &
6666 renderOption ?: RenderOption ;
6767 isLoading ?: boolean ;
6868 errorMsg ?: string ; // If errorMsg is defined, we show dropDown's error state with the message.
69+ helperText ?: string ;
6970 } ;
7071export interface DefaultDropDownValueNodeProps {
7172 selected : DropdownOption ;
@@ -309,14 +310,20 @@ const SelectedIcon = styled(Icon)`
309310const ErrorMsg = styled . span `
310311 ${ ( props ) => getTypographyByKey ( props , "p3" ) } ;
311312 color: ${ Colors . POMEGRANATE2 } ;
312- margin: 6px 0px 10px ;
313+ margin-top: 8px ;
313314` ;
314315
315316const ErrorLabel = styled . span `
316317 ${ ( props ) => getTypographyByKey ( props , "p1" ) } ;
317318 color: ${ Colors . POMEGRANATE2 } ;
318319` ;
319320
321+ const HelperText = styled . span `
322+ ${ ( props ) => getTypographyByKey ( props , "p3" ) } ;
323+ color: ${ Colors . GRAY } ;
324+ margin-top: 8px;
325+ ` ;
326+
320327function DefaultDropDownValueNode ( {
321328 errorMsg,
322329 renderNode,
@@ -455,12 +462,20 @@ export default function Dropdown(props: DropdownProps) {
455462 SelectedValueNode = DefaultDropDownValueNode ,
456463 renderOption,
457464 errorMsg = "" ,
465+ helperText = "" ,
458466 } = { ...props } ;
459467 const [ isOpen , setIsOpen ] = useState < boolean > ( false ) ;
460468 const [ selected , setSelected ] = useState < DropdownOption > ( props . selected ) ;
461469
470+ const closeIfOpen = ( ) => {
471+ if ( isOpen ) {
472+ setIsOpen ( false ) ;
473+ }
474+ } ;
475+
462476 useEffect ( ( ) => {
463477 setSelected ( props . selected ) ;
478+ closeIfOpen ( ) ;
464479 } , [ props . selected ] ) ;
465480
466481 const optionClickHandler = useCallback (
@@ -474,7 +489,7 @@ export default function Dropdown(props: DropdownProps) {
474489 ) ;
475490
476491 const disabled = props . disabled || isLoading || ! ! errorMsg ;
477- const downIconColor = errorMsg ? Colors . POMEGRANATE2 : "" ;
492+ const downIconColor = errorMsg ? Colors . POMEGRANATE2 : Colors . DARK_GRAY ;
478493
479494 const dropdownTrigger = props . dropdownTriggerIcon ? (
480495 < DropdownTriggerWrapper
@@ -516,6 +531,9 @@ export default function Dropdown(props: DropdownProps) {
516531 ) }
517532 </ Selected >
518533 { errorMsg && < ErrorMsg > { errorMsg } </ ErrorMsg > }
534+ { helperText && ! isOpen && ! errorMsg && (
535+ < HelperText > { helperText } </ HelperText >
536+ ) }
519537 </ DropdownSelect >
520538 ) ;
521539 return (
0 commit comments