Vux: [Bug Report] @on-click-clear-icon事件无效

Created on 11 Apr 2019  ·  9Comments  ·  Source: airyland/vux

VUX version

2.9.3

OS/Browsers version

chrome70.0.3510.2 firefox 66.0.1

Vue version

2.6.10

Code

<template>
  <div class="input-compontent">
    <div class="header-common">
      <x-header :left-options="{backText: ''}">input</x-header>
    </div>
    <group>
      <x-input
        title="姓名"
        v-model="value"
        type="text"
        placeholder="请输入姓名"
        @on-click-clear-icon="handleClear"
        @on-blur="blurChange"
        is-type="validFrom"
      ></x-input>
    </group>
  </div>
</template>
<script>
import { XHeader, XInput, Group } from 'vux'
export default {
  data () {
    return {
      value: ''
    }
  },
  methods: {
    handleClear () {
      console.log('clear')
    },
    blurChange () {
      console.log('blur')
    }
  },
  components: {
    XHeader,
    XInput,
    Group
  }
}
</script>

Steps to reproduce

输入内容,点击X号,事件不执行
猜测是因为先执行blur事件,叉号隐藏了,导致点击不到叉号

What is Expected?

可以执行

What is actually happening?

不执行

Most helpful comment

下面的兄弟方法比我的好,在组件源码上修改onBlur事件
this.setTouched()
this.validate()
let timer = setTimeout(() => {
this.isFocus = false
clearTimeout(timer)
}, 10)
this.$emit('on-blur', this.currentValue, $event)

All 9 comments

2.9.0后好像x-input的清空都有问题,暂时回退到2.8.1了...

下面的兄弟方法比我的好,在组件源码上修改onBlur事件
this.setTouched()
this.validate()
let timer = setTimeout(() => {
this.isFocus = false
clearTimeout(timer)
}, 10)
this.$emit('on-blur', this.currentValue, $event)

同问

按照大佬指示,已经改源码了

在组件源码上 onBlur事件加上最后一个暂时解决了
this.setTouched()
this.validate()
this.isFocus = false
this.$emit('on-blur', this.currentValue, $event)
加上下面这一行👇👇👇
this.isFocus = true

这个方法有一个问题的,就是出现x后,再移开鼠标,x依旧会显示

在组件源码上 onBlur事件加上最后一个暂时解决了
this.setTouched()
this.validate()
this.isFocus = false
this.$emit('on-blur', this.currentValue, $event)
加上下面这一行👇👇👇
this.isFocus = true

这个方法有一个问题的,就是出现x后,再移开鼠标,x依旧会显示

好像是的...那就等bug修复了,暂时先用2.8.1

在组件源码上 onBlur事件加上最后一个暂时解决了
this.setTouched()
this.validate()
this.isFocus = false
this.$emit('on-blur', this.currentValue, $event)
加上下面这一行👇👇👇
this.isFocus = true

这个方法有一个问题的,就是出现x后,再移开鼠标,x依旧会显示

let timer = setTimeout(() => {
this.isFocus = false;
clearTimeout(timer);
}, 10);

再加个定时器

The order of events in non-iOS devices is: mousedown -> blur -> mouseup -> click, so using mousedown instead of click in non-iOS and keeping click in iOS will solve this issue . Please see my PR.

Was this page helpful?
0 / 5 - 0 ratings