Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix double tap on iOS devices #1858

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/action-handler-directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ActionHandler extends HTMLElement implements ActionHandlerInterface {

protected holdTimer = new Timer();
protected doubleClickTimer = new Timer();

private cancelled = false;
protected held = false;
protected started = false;

Expand All @@ -47,6 +47,7 @@ class ActionHandler extends HTMLElement implements ActionHandlerInterface {
document.addEventListener(
ev,
() => {
this.cancelled = true;
this.holdTimer.stop();
},
{ passive: true },
Expand Down Expand Up @@ -79,6 +80,7 @@ class ActionHandler extends HTMLElement implements ActionHandlerInterface {
});

const start = (): void => {
this.cancelled = false;
this.held = false;
this.holdTimer.start(this.holdTime, () => {
this.held = true;
Expand Down Expand Up @@ -110,7 +112,7 @@ class ActionHandler extends HTMLElement implements ActionHandlerInterface {
}

if (
['touchend', 'touchcancel'].includes(ev.type) &&
(ev.type === 'touchcancel' || (ev.type === 'touchend' && this.cancelled)) &&
// This action handler by default relies on synthetic click events for
// touch devices, in order to ensure that embedded cards (e.g. WebRTC)
// can use stock click handlers. The exception is for hold events.
Expand Down
Loading