diff --git a/src/molecules/select/select-async.tsx b/src/molecules/select/select-async.tsx index 78fae18d..94e7ff82 100644 --- a/src/molecules/select/select-async.tsx +++ b/src/molecules/select/select-async.tsx @@ -1,6 +1,7 @@ import noop from 'lodash/noop' -import React, { FC } from 'react' +import React, { FC, forwardRef } from 'react' import ReactAsyncSelect, { AsyncProps } from 'react-select/async' +import Select from 'react-select/base' import * as theme from '../../theme' import { cssClass, filterStyles, selectStyles } from '../../utils' @@ -10,7 +11,7 @@ interface SelectProps extends AsyncProps { variant?: 'default' | 'filter' } -export const SelectAsync: FC = (props) => { +export const SelectAsync: FC = forwardRef, SelectProps>((props, ref) => { const { value, onChange, variant, ...selectProps } = props const styles = variant === 'filter' ? filterStyles(theme) : selectStyles(theme) @@ -26,9 +27,10 @@ export const SelectAsync: FC = (props) => { onChange={handleChange} isClearable {...selectProps} + ref={ref} /> ) -} +}) SelectAsync.defaultProps = { variant: 'default', diff --git a/src/molecules/select/select.tsx b/src/molecules/select/select.tsx index 2ad5bf13..9ac643fe 100644 --- a/src/molecules/select/select.tsx +++ b/src/molecules/select/select.tsx @@ -1,6 +1,7 @@ import noop from 'lodash/noop' -import React, { FC } from 'react' -import ReactSelect, { Props } from 'react-select' +import React, { FC, forwardRef } from 'react' +import ReactSelect, { GroupBase, Props } from 'react-select' +import SelectType from 'react-select/base' import * as theme from '../../theme' import { cssClass, filterStyles, selectStyles } from '../../utils' @@ -10,7 +11,7 @@ interface SelectProps extends Props { variant?: 'default' | 'filter' } -export const Select: FC = (props) => { +export const Select: FC = forwardRef>, SelectProps>((props, ref) => { const { value, onChange, variant, ...selectProps } = props const styles = variant === 'filter' ? filterStyles(theme) : selectStyles(theme) @@ -26,9 +27,10 @@ export const Select: FC = (props) => { onChange={handleChange} isClearable {...selectProps} + ref={ref} /> ) -} +}) Select.defaultProps = { variant: 'default',