Browse Source

数字键盘第一次点击不上去bug修改

zhouna 6 years ago
parent
commit
fecc18d392
1 changed files with 16 additions and 9 deletions
  1. 16 9
      src/components/NumberDrop/index.jsx

+ 16 - 9
src/components/NumberDrop/index.jsx

@@ -42,9 +42,16 @@ class NumberDrop extends Component{
   }
   select(text){        //选中键盘上数字事件
     const {handleSelect,ikey,suffix,prefix,mainSaveText} = this.props;
-    this.setState({
-      hasSelect:true
-    });
+    if(!text){
+      this.setState({
+        placeholder:this.props.placeholder
+      });
+    }else{
+      this.setState({
+        hasSelect:true
+      });
+    }
+
     handleSelect&&handleSelect({ikey,text,suffix,prefix,mainSaveText});
   }
   handleNumFocus(e){       //数字框可编辑状态下聚集事件,处理是否显示下拉等
@@ -93,18 +100,18 @@ class NumberDrop extends Component{
   }
   numInpBlur(e){        //数字框失焦,保存值到store中
     e.stopPropagation();
+    if(this.props.show){      //修改清空后第一次点击键盘不触发click事件bug
+      return;
+    }
     const that = this;
-    setTimeout(function(){      //第一次选中数字时placeholder闪一下优化
-      if(!that.state.hasSelect&&!e.target.innerText.trim()){
+    //setTimeout(function(){      //第一次选中数字时placeholder闪一下优化
+      if(!e.target.innerText.trim()){
         that.setState({
           placeholder:that.props.placeholder
         });
       }
-    },100);
+    //},100);
 
-    if(this.props.show){      //修改清空后第一次点击键盘不触发click事件bug
-      return;
-    }
     this.setState({
       hasSelect:false
     });