|
@@ -18,6 +18,8 @@ class SearchOption extends React.Component {
|
|
|
}
|
|
|
this.textInput = React.createRef();
|
|
|
this.handleClearVal = this.handleClearVal.bind(this);
|
|
|
+ this.handleFocus = this.handleFocus.bind(this);
|
|
|
+ this.handleBlur = this.handleBlur.bind(this);
|
|
|
}
|
|
|
|
|
|
/*componentWillReceiveProps(nextProps){
|
|
@@ -47,19 +49,31 @@ class SearchOption extends React.Component {
|
|
|
handleChangeValue('');
|
|
|
}
|
|
|
handleInput(e){
|
|
|
+ const { handleChangeValue } = this.props;
|
|
|
if((e.target.value).trim() != ''){
|
|
|
- this.props.handleChangeValue(e.target.value);
|
|
|
+ handleChangeValue(e.target.value);
|
|
|
this.setState({
|
|
|
val:e.target.value,
|
|
|
show:true
|
|
|
})
|
|
|
}else{
|
|
|
- this.handleClearVal()
|
|
|
+ // this.handleClearVal()
|
|
|
this.setState({
|
|
|
show:false
|
|
|
})
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
+ handleFocus(){
|
|
|
+ if(this.state.val.trim() != ''){
|
|
|
+ return;
|
|
|
+ }else{
|
|
|
+ this.setState({border:true})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ handleBlur(){
|
|
|
+ this.setState({border:false,val:''})
|
|
|
+ }
|
|
|
render() {
|
|
|
const { children,visible } = this.props;
|
|
|
const { show } = this.state;
|
|
@@ -72,14 +86,8 @@ class SearchOption extends React.Component {
|
|
|
type="text"
|
|
|
maxLength="30"
|
|
|
ref={this.textInput}
|
|
|
- onFocus={()=>{
|
|
|
- if(this.state.val.trim() != ''){
|
|
|
-
|
|
|
- }else{
|
|
|
- this.setState({border:true})
|
|
|
- }
|
|
|
- }}
|
|
|
- onBlur={()=>{this.setState({border:false,val:''})}}
|
|
|
+ onFocus={this.handleFocus}
|
|
|
+ onBlur={this.handleBlur}
|
|
|
onInput={(e) => {
|
|
|
this.handleInput(e)
|
|
|
}}
|