瀏覽代碼

主诉单选带输入字数限制bug修改

zhouna 6 年之前
父節點
當前提交
b0c0fb5899
共有 1 個文件被更改,包括 12 次插入1 次删除
  1. 12 1
      src/components/RadioInpDrop/index.jsx

+ 12 - 1
src/components/RadioInpDrop/index.jsx

@@ -161,7 +161,7 @@ class RadioInpDrop extends Component{
       }else{
         lengths = mainText.length + val.length;
       }
-      console.log("val:",val,"preVal:",preText,"mainText:",mainText,"lengths:",lengths,this.state.texts)
+      //console.log("val:",val,"preVal:",preText,"mainText:",mainText,"lengths:",lengths,this.state.texts)
       if(lengths >= config.limited){
         Notify.info(config.limitText);
         this.setState({
@@ -225,6 +225,7 @@ class RadioInpDrop extends Component{
 class InputComp extends Component{
   constructor(props){
     super(props);
+    this.$inp = React.createRef();
     this.handleBlur = this.handleBlur.bind(this);
   }
   handleBlur(e){
@@ -234,9 +235,19 @@ class InputComp extends Component{
     e.target.innerText = '';
     handleInp(index,text);
   }
+  componentWillReceiveProps(next){
+    if(next.over&&!this.props.over){
+      const inp = this.$inp.current;
+      const value = this.props.value;
+      setTimeout(function(){
+        inp.innerText = value;
+      })
+    }
+  }
   render(){
     const {editable,value} = this.props;
     return editable?<span contentEditable={true}
+                          ref={this.$inp}
                  className={style['inner-inp']}
                  onClick={(e)=>{e.stopPropagation()}}
                  onFocus={(e)=>{e.stopPropagation()}}