From f872a01d5318e2092c8ec7434d5060139f3fd32a Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Tue, 15 Sep 2026 12:43:24 -0400 Subject: [PATCH] Dispatch a synthetic click on quick taps touchstart's preventDefault suppresses the click events that foliate's link handling and the overlayer's highlight hit-testing depend on; dispatch one at the tapped element so internal links and the highlight edit popover work on touch as on desktop. --- paginator.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/paginator.js b/paginator.js index ede314b..9adc0f8 100644 --- a/paginator.js +++ b/paginator.js @@ -733,10 +733,13 @@ export class Paginator extends HTMLElement { if (wasSelecting || e.changedTouches.length !== 1) return const touch = e.changedTouches[0] // touchstart's preventDefault suppresses click - // events; follow links directly - const link = doc.elementFromPoint(touch.clientX, touch.clientY) - ?.closest('a') - link?.click() + // events; dispatch one so foliate's link handling and + // the overlayer's highlight hit-testing (the edit + // popover) behave as on desktop + const el = doc.elementFromPoint(touch.clientX, touch.clientY) + el?.dispatchEvent(new (doc.defaultView ?? window).MouseEvent( + 'click', { clientX: touch.clientX, clientY: touch.clientY, + bubbles: true, cancelable: true })) }) doc.addEventListener('touchcancel', clearGesture) doc.addEventListener('contextmenu', e => e.preventDefault())