Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/molecules/select/select-async.tsx
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -10,7 +11,7 @@ interface SelectProps extends AsyncProps<unknown, boolean, any> {
variant?: 'default' | 'filter'
}

export const SelectAsync: FC<SelectProps> = (props) => {
export const SelectAsync: FC<SelectProps> = forwardRef<Select<any, boolean, any>, SelectProps>((props, ref) => {
const { value, onChange, variant, ...selectProps } = props
const styles = variant === 'filter' ? filterStyles(theme) : selectStyles(theme)

Expand All @@ -26,9 +27,10 @@ export const SelectAsync: FC<SelectProps> = (props) => {
onChange={handleChange}
isClearable
{...selectProps}
ref={ref}
/>
)
}
})

SelectAsync.defaultProps = {
variant: 'default',
Expand Down
10 changes: 6 additions & 4 deletions src/molecules/select/select.tsx
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -10,7 +11,7 @@ interface SelectProps extends Props {
variant?: 'default' | 'filter'
}

export const Select: FC<SelectProps> = (props) => {
export const Select: FC<SelectProps> = forwardRef<SelectType<any, boolean, GroupBase<unknown>>, SelectProps>((props, ref) => {
const { value, onChange, variant, ...selectProps } = props
const styles = variant === 'filter' ? filterStyles(theme) : selectStyles(theme)

Expand All @@ -26,9 +27,10 @@ export const Select: FC<SelectProps> = (props) => {
onChange={handleChange}
isClearable
{...selectProps}
ref={ref}
/>
)
}
})

Select.defaultProps = {
variant: 'default',
Expand Down