瀏覽代碼

文本模式关标bug回退

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

+ 12 - 19
src/common/components/Textarea/index.jsx

@@ -17,7 +17,7 @@ class Textarea extends Component {
     this.$dom = React.createRef();
     this.handleInput = this.handleInput.bind(this);
     this.handleFocus = this.handleFocus.bind(this);
-    this.handleBlur = this.handleBlur.bind(this);
+    //this.handleBlur = this.handleBlur.bind(this);
     this.handleKeydown = this.handleKeydown.bind(this);
   }
   handleFocus(){            //初始显示props中的值,focus已经显示输入的值,避免值更新闪烁
@@ -36,7 +36,7 @@ class Textarea extends Component {
     const text = e.target.innerText || e.target.innerHTML;
     const stimer = this.state.timer;
     if(boxMark=='1'&&text.length>config.limited){           //主诉字符数限制
-      e.target.innerText?(e.target.innerText = text.substr(0,config.limited)):(e.target.innerHTML = text.substr(0,config.limited)); 
+      e.target.innerText?(e.target.innerText = text.substr(0,config.limited)):(e.target.innerHTML = text.substr(0,config.limited));
       e.target.blur();
       Notify.error(config.limitText);
       if(overFlag){
@@ -59,7 +59,7 @@ class Textarea extends Component {
     })
 
     //存值到store
-    // handleInput&&handleInput({text});
+    handleInput&&handleInput({text});
     //右侧推送--延时推送
     clearTimeout(stimer);
     let timer = setTimeout(function(){
@@ -70,6 +70,14 @@ class Textarea extends Component {
       timer
     });
   }
+  handleKeydown(e){
+    const {boxMark} = this.props;
+    const ev = e||window.event;
+    if(+boxMark==1){
+      //禁止回车事件
+      if(ev.keyCode==13){return false;}
+    }
+  }
   shouldComponentUpdate(next){
     if(JSON.stringify(next) == JSON.stringify(this.props)){
       return false;
@@ -85,7 +93,7 @@ class Textarea extends Component {
   componentDidMount(){
     const {value} = this.props;
     if(value){
-      this.$dom.current.innerText?(this.$dom.current.innerText = value||''):(this.$dom.current.innerHTML=value||'');
+      this.$dom.current.innerText?(this.$dom.current.innerText = value||''):(this.$dom.current.innerText=value||'');
     }
     if(isIE()){
       $(this.$dom.current).onIe8Input(function(e){
@@ -93,20 +101,6 @@ class Textarea extends Component {
       },this);
     }
   }
-  handleBlur(){
-    const {handleInput} = this.props;
-    const text = this.$dom.current.innerText||this.$dom.current.innerHTML;
-    //存值到store
-    handleInput&&handleInput({text});
-  }
-  handleKeydown(e){
-    const {boxMark} = this.props;
-    const ev = e||window.event;
-    if(+boxMark==1){
-      //禁止回车事件
-      if(ev.keyCode==13){return false;}
-    }
-  }
   render() {
     const { title } = this.props;
     return (
@@ -118,7 +112,6 @@ class Textarea extends Component {
              ref={this.$dom}
              contentEditable={true}
              onInput={this.handleInput}
-             onBlur={this.handleBlur}
              onkeydown={this.handleKeydown}>
         </div>
       </div>