Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

222
Views
Is the `click` event guaranteed to fire right after `touchend`, before `touchend`'s event handler can run?

There's a Chrome bug where click doesn't fire after a touchend: https://bugs.chromium.org/p/chromium/issues/detail?id=1141207#c10

I want to simulate a click using dispatchEvent:

let timer: number | null = null;
window.addEventListener('touchend', event => {
  if (timer) {
    clearTimeout(timer);
  }
  timer = window.setTimeout(() => {
    event.target?.dispatchEvent(new Event('click', {
      bubbles: true,
      cancelable: true,
    }));
  }, 0);
});

window.addEventListener('click', () => {
  if (timer) {
    clearTimeout(timer);
  }
});

I'm assuming it'll be impossible for the timeout callback to run before the click handler runs (if the click event occurs). With this assumption, I can make the timeout delay 0. If this assumption is false, then I'd need a longer delay, maybe 1-2 frames. Is click guaranteed to fire right after touchend, before touchend's event handler runs?

Are there

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!