diff --git a/packages/core/src/components/SingleSelect/Options/Options.tsx b/packages/core/src/components/SingleSelect/Options/Options.tsx index 603799c36..f5d5cdc58 100644 --- a/packages/core/src/components/SingleSelect/Options/Options.tsx +++ b/packages/core/src/components/SingleSelect/Options/Options.tsx @@ -1,26 +1,34 @@ -import { WithStyle } from '@medly-components/utils'; +import { useCombinedRefs, WithStyle } from '@medly-components/utils'; import type { FC } from 'react'; -import { forwardRef, memo } from 'react'; +import { forwardRef, memo, useEffect, useRef } from 'react'; import Option from './Option'; import * as Styled from './Options.styled'; import { OptionsProps } from './types'; const Component: FC = memo( - forwardRef(({ options, onOptionClick, hasError, ...restProps }, ref) => ( - - {options.map(option => ( - - )) + forwardRef(({ options, onOptionClick, hasError, ...restProps }, ref) => { + const optionsRef = useCombinedRefs(ref, useRef(null)); + + useEffect(() => { + optionsRef?.current?.scrollIntoView({ behavior: 'smooth' }); + }, []); + + return ( + + {options.map(option => ( + + ); + }) ); Component.defaultProps = { isNested: false