Browse Source

chrome41,点击标签光标落入span;bug1880

luolei 6 years ago
parent
commit
2a07df3507

+ 5 - 1
src/common/components/EditableSpan/index.jsx

@@ -37,6 +37,7 @@ class EditableSpan extends Component{
     this.handleKeydown = this.handleKeydown.bind(this);
     this.handleKeyup = this.handleKeyup.bind(this);
     this.moveEnd = this.moveEnd.bind(this);
+    this.handleClick = this.handleClick.bind(this);
   }
   handleFocus(e){
     e.stopPropagation();
@@ -279,6 +280,9 @@ class EditableSpan extends Component{
       this.$span.current.innerText?(this.$span.current.innerText = next.value||''):(this.$span.current.innerHTML = next.value||'');
     }
   }
+  handleClick(e){
+    $(this.$span.current).attr({"contentEditable":true}).focus()
+  }
   componentDidMount(){
     const {value} = this.props;
     const that = this;
@@ -302,7 +306,6 @@ class EditableSpan extends Component{
         sel.removeAllRanges();
       }
     }*/
-
   getClass(){
     const {full,value,saveText,i} = this.props;
     const preSelected = saveText[i-1];
@@ -320,6 +323,7 @@ class EditableSpan extends Component{
                  onFocus={this.handleFocus}
                  onBlur={this.handleBlur}
                  onkeydown={this.handleKeydown}
+                 onclick={this.handleClick}
                  onkeyup={this.handleKeyup}></span>;
 
   }

+ 3 - 1
src/components/RadioDrop/index.jsx

@@ -71,13 +71,15 @@ class RadioDrop extends Component{
     handleSelect&&handleSelect({ikey,id:item.id,text,mainSaveText,value});
   }
   handleShow(e){
-    //e.stopPropagation();
+    // e.stopPropagation();
     const {handleShow,ikey,id,patId} = this.props;
     const that = this;
     const timer = setTimeout(function(){
       if (that.state.editable) {//如果处于编辑状态点击不显示下拉框
         return
       }else {
+        document.activeElement.blur()//chrome41有效,但是失去焦点的span仍能编辑
+        $(e.target).parent().prev().attr({"contentEditable":false})
         handleShow && handleShow({ikey,id:patId||id});
       }
     },300);

+ 2 - 0
src/components/RadioInpDrop/index.jsx

@@ -82,6 +82,8 @@ class RadioInpDrop extends Component{
       if (that.state.editable) {//如果处于编辑状态点击不显示下拉框
         return
       }else {
+        document.activeElement.blur()//chrome41有效,但是失去焦点的span仍能编辑
+        $(e.target).parent().parent().prev().attr({"contentEditable":false})
         handleShow && handleShow({ikey,id:patId||id});
       }
     },300);

+ 2 - 0
src/components/SpreadDrop/index.jsx

@@ -76,6 +76,8 @@ class SpreadDrop extends Component{
       if (that.state.editable) {//如果处于编辑状态点击不显示下拉框
         return
       }else{
+        document.activeElement.blur()//chrome41有效,但是失去焦点的span仍能编辑
+        $(e.target).parent().prev().attr({"contentEditable":false})
         handleShow&&handleShow({ikey,placeholder,flag,id,value,tagType,type});
       }
     },300)