1
0

Prevent duplicate tap events (#436)

* prevent duplicate click events on mobile

* prevent duplicate mouse events on mobile safari

* only prevent default event on links

I think I misunderstood what was going on originally, mouse and click
weren't both triggering  it was the default event from the a reference.

So, only prevent default behavior on a e;ements, since default handlers
are needed on navigation.

Oddly, this I've only noticed this fixing navigation on firefox simulator.
It wasn't needed on firefox.
This commit is contained in:
Ian Shehadeh 2023-06-28 13:36:22 -04:00 committed by GitHub
parent 629d25e0e3
commit fee2c5928e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -971,6 +971,14 @@ export class Editor {
if (touchCount === 0) {
safeRun(async () => {
const touch = event.changedTouches.item(0)!;
if (!event.altKey && event.target instanceof Element) {
// prevent the browser from opening the link twice
const parentA = event.target.closest("a");
if (parentA) {
event.preventDefault();
}
}
const clickEvent: ClickEvent = {
page: pageName,
ctrlKey: event.ctrlKey,
@ -986,6 +994,7 @@ export class Editor {
}
touchCount = 0;
},
mousedown: (event: MouseEvent, view: EditorView) => {
safeRun(async () => {
const pos = view.posAtCoords(event);