material
material copied to clipboard
gesture: prevent firing double mousedown events
There are some situations when the gesture handler will cause two mousedown events to be fired for a single touch on mobile.
This is problematic for anything that depends on mousedown to, say, toggle an open/closed state.
I think I've also just hit the same issue, although please let me know if i've unearthed something slightly different…
Here's a reduce test case of how I found this issue in our app.
Steps to reproduce:
- Open this Codepen
- Open DevTools and ensure that Device Emulation is disabled (so no UA string overrides are in effect)
- Click the icon button and notice a single console log
- Enable Device Emulation mode and select a preset, e.g. Pixel 2
- Refresh the page
- Click the button again
- Note the double
console.log
My current workaround (which is a bit of a cop out, since I only need to support Chrome for this project)…
- Ensure that you have a suitable viewport meta tag, setting this ensures that the browser disables the tap delay (See this Google Developers article).
- Disable the Angular Material click-hijacking code as described in this comment
Here's another Codepen with my workaround applied. Perform the same reproduction steps outlined above to verify that it works.