Browse Source

光标移动获取搜索框的位置

Luolei 6 years ago
parent
commit
2326781c5a
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/common/components/EditableSpan/index.jsx

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

@@ -146,9 +146,9 @@ class EditableSpan extends Component{
 
   handleKeydown(e){
     const ev = e||window.event;
-    const {i} = this.props;
+    const {i,setSearchLocation} = this.props;
     const target = ev.target||ev.srcElement;
-    let innerVal = target.innerText;
+    let innerVal = target.innerText || target.innerHTML,ele,boxTop;
     //禁止回车事件
     if(ev.keyCode==13){return false;}
     //backspace事件
@@ -185,6 +185,9 @@ class EditableSpan extends Component{
         obj.focus();
       }
     }
+    ele = document.activeElement;
+    boxTop = target.innerText?getPageCoordinate(e).boxTop:$(ele).offset().top+30;
+    setSearchLocation(boxTop,ele.offsetLeft)     //搜索框的位置动态获取
   }  
   handleKeyup(e){
     const {boxMark,handleKeydown,i,value,removeId,handleClear,delSingleLable,setSearchLocation} = this.props;