From 2ec742485b499947422a39ebea3e684ea7db704c Mon Sep 17 00:00:00 2001 From: Diogo de Azevedo Silva Date: Thu, 2 Mar 2023 12:33:21 -0300 Subject: [PATCH 1/2] fix: add forward ref on select-async --- src/molecules/select/select-async.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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', From d3fe5260ca801b780b7a0f0c2554d29649d0bcdf Mon Sep 17 00:00:00 2001 From: Diogo de Azevedo Silva Date: Thu, 2 Mar 2023 14:55:09 -0300 Subject: [PATCH 2/2] fix: add forward ref on select --- src/molecules/select/select.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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',