From 2e392e80d37d480946e6d1d697a2a6e8c3173f47 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sun, 13 Sep 2026 18:26:47 -0400 Subject: [PATCH] Retry the touch selection clamp after the gesture ends --- paginator.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/paginator.js b/paginator.js index fab3d21..7282663 100644 --- a/paginator.js +++ b/paginator.js @@ -613,8 +613,22 @@ export class Paginator extends HTMLElement { if (!range) return const sel = doc.getSelection() if (!sel.rangeCount) return - if (touchSelecting && sel.type === 'Range') + if (touchSelecting && sel.type === 'Range') { this.#clampTouchSelection(sel, doc) + // Chrome ignores (or re-maps) selection writes made from + // JS while the touch selection gesture is active, and no + // pointer or touch event reaches the document when the + // finger lifts after the takeover — the only signal is + // the last selectionchange, mid-gesture. Retry after the + // gesture has most likely ended. + const clampLater = () => { + const s = doc.getSelection() + if (s && s.rangeCount && s.type === 'Range') + this.#clampTouchSelection(s, doc) + } + setTimeout(clampLater, 150) + setTimeout(clampLater, 500) + } if (isPointerSelecting && sel.type === 'Range') checkPointerSelection(range, sel) else if (isKeyboardSelecting) {