element-plus [Bug Report] el-input-number with double touch on trackpad will increase for twice

7kjnsjlb  于 2022-10-21  发布在  其他
关注(0)|答案(6)|浏览(176)

About this component there is a another bug.
When try to interact with el-input-number with double touch on trackpad(double touch == click on trackpad), count will increase for twice.
It's caused by the impl of repeat-click.
There is a delay between mouseup and mousedown event when trigger click on trackpad, about 300ms, but the trigger
threshold of repeat-click only 100ms. So click event will repeat for serveral times.
My resolution is just add a setTimeout before the setInterval , like this:

let interval = null
    let startTime: number
    const handler = () => binding.value && binding.value()
    const clear = () => {
      if (Date.now() - startTime < 100) {
        handler()
      }
      cleartTimeout(interval)
      clearInterval(interval)
      interval = null
    }

    on(el, 'mousedown', (e: MouseEvent) => {
      if ((e as any).button !== 0) return
      startTime = Date.now()
      once(document as any, 'mouseup', clear)
      clearInterval(interval)
      handler();
      // delay 300ms before repeate click event
      interval = setTimeout(() => { interval = setInterval(handler, 100) }, 300);
    })
  • Originally posted by @KawaiiZapic in #3334 (comment)*
yks3o0rb

yks3o0rb1#

@KawaiiZapic Open a new issue to discuss this problem.

Is this problem related to #2997 ?

brc7rcf0

brc7rcf02#

Hello @adaex. Please provide an online reproduction demo by clicking this link or a minimal GitHub repository.

你好 @adaex, 请提供一个可复现问题的链接以便于我们帮你排查问题。可以通过点击 此处 创建或者提供一个最小化的 GitHub 仓库。

b4wnujal

b4wnujal3#

@KawaiiZapic Open a new issue to discuss this problem.

Is this problem related to #2997 ?

Maybe that is, I'm not sure.
Author does not provide any device info, maybe fix this first, and ask @causingh to check.
I'm using Windows 10, Chrome 92, can reproduce this problem.
But I'm not sure this is a manufacturer specific problem or something else, we need more device to test.

  • So I write a simple click delay test -> TP
j2qf4p5b

j2qf4p5b4#

There is a mistake, justone touchon trackpad, not double touch.
And I test my trackpad click delay:

about 200ms, still one time larger than threshold of repeat-click.

oxf4rvwz

oxf4rvwz5#

Uh, I'm getting different results on my computer(MacBook Pro, macOS 11.5.2).

On my computer, double-clicking (click twice quickly) has the same result, the delay is also about 6ms, I can't reproduce more than 100ms.

h22fl7wq

h22fl7wq6#

Uh, I'm getting different results on my computer(MacBook Pro, macOS 11.5.2).

On my computer, double-clicking (click twice quickly) has the same result, the delay is also about 6ms, I can't reproduce more than 100ms.

I ask somebody use trackpad on Windows device to take a test.
In results, Windows 11 has a 100ms delay, Windows 10 has 200ms delay (based on 4 samples, 1 on Windows 11, 3 on Windows 10), I don't know what browser they use, maybe Edge or Chrome.
It's too confusing, therebefore only difference between browser, now we need to handle difference between operate system.😖

相关问题