@@ -3,8 +3,25 @@ import PropTypes from 'prop-types';
33
44import './input.scss' ;
55
6+ const getInputString = ( filter , value ) => {
7+ if ( typeof filter === 'string' ) {
8+ return filter ;
9+ }
10+
11+ if ( typeof value === 'string' ) {
12+ return value ;
13+ }
14+
15+ if ( Array . isArray ( value ) && typeof value [ 0 ] === 'string' ) {
16+ return value [ 0 ] ;
17+ }
18+
19+ return '' ;
20+ } ;
21+
622const Input = ( { inputRef, isSearchable, isDisabled, getInputProps, value, ...props } ) => {
723 const inputProps = getInputProps ( { disabled : isDisabled } ) ;
24+ const initialInputValue = getInputString ( inputProps . value , value ) ;
825 return (
926 < input
1027 value = ""
@@ -13,7 +30,7 @@ const Input = ({ inputRef, isSearchable, isDisabled, getInputProps, value, ...pr
1330 ref = { inputRef }
1431 { ...{
1532 ...inputProps ,
16- value : inputProps . value || '' ,
33+ value : initialInputValue ,
1734 onKeyDown : ( event , ...args ) => {
1835 event . stopPropagation ( ) ;
1936 inputProps . onKeyDown ( event , ...args ) ;
@@ -29,7 +46,7 @@ Input.propTypes = {
2946 isSearchable : PropTypes . bool ,
3047 isDisabled : PropTypes . bool ,
3148 getInputProps : PropTypes . func . isRequired ,
32- value : PropTypes . string
49+ value : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . arrayOf ( PropTypes . string ) ] )
3350} ;
3451
3552export default Input ;
0 commit comments