From 620f7a4ce93b73f68357fd657a88344d1473fa89 Mon Sep 17 00:00:00 2001 From: ej9x Date: Sat, 8 Jun 2019 22:40:48 +0300 Subject: [PATCH] feat(Select): add passed props to control search value --- src/components/Select/Select.js | 6 ++++++ src/components/SelectField/SelectField.js | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/components/Select/Select.js b/src/components/Select/Select.js index e9e1cb83..9e6e5d07 100644 --- a/src/components/Select/Select.js +++ b/src/components/Select/Select.js @@ -10,6 +10,8 @@ import { type Theme, COLORS, Z_INDEX } from '../../theme'; type SelectProps = {| options: Array<{ label: mixed, value: string }>, onChange: (value: mixed, event?: SyntheticInputEvent) => void, + inputValue?: string, + onInputChange ?: (value: string, event?: SyntheticInputEvent) => void, placeholder?: string, value?: any | any[], loading?: boolean, @@ -126,6 +128,8 @@ class Select extends React.Component { withPortal, theme, formatOptionLabel, + inputValue, + onInputChange, ...rest } = this.props; @@ -152,6 +156,8 @@ class Select extends React.Component { value={ selectValue } components={ components } formatOptionLabel={ formatOptionLabel } + inputValue={ inputValue } + onInputChange={ onInputChange } /> ); diff --git a/src/components/SelectField/SelectField.js b/src/components/SelectField/SelectField.js index 85063a27..d3cbdf87 100644 --- a/src/components/SelectField/SelectField.js +++ b/src/components/SelectField/SelectField.js @@ -19,6 +19,10 @@ type SelectFieldProps = { meta?: MetaType, /** custom value component */ valueComponent ?: React$Node, + /** controlled search value */ + inputValue?: string, + /** callback to control search value */ + onInputChange?: (value: string, event?: SyntheticInputEvent) => void, }; class SelectField extends React.Component {