From 63a5dbf3e36e47cd8d1b9db22901ba29cb0abd83 Mon Sep 17 00:00:00 2001 From: John Factotum <50942278+johnfactotum@users.noreply.github.com> Date: Thu, 12 Dec 2024 09:24:24 +0800 Subject: [PATCH] Don't scroll to anchor if caret's moved by pointer In Safari, clicking on links triggers `selectionchange`. Since we do not move the caret when flipping through pages, when you have flipped to the next or previous pages and click on any link, it would take you back to the caret instead of activating the link. Note that the bug occurs in Safari 17 but not in WebKitGTK 2.46. Not sure if there's a way to fix this and still retain the "set anchor to caret on click" behavior. But I guess this behavior isn't really that essential, anyway. So removing it for now. Fixes #44 --- paginator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paginator.js b/paginator.js index 97d02db..0dd424b 100644 --- a/paginator.js +++ b/paginator.js @@ -596,7 +596,7 @@ export class Paginator extends HTMLElement { if (!sel.rangeCount) return if (isPointerSelecting && sel.type === 'Range') checkPointerSelection(range, sel) - else if (isKeyboardSelecting || sel.type === 'Caret') { + else if (isKeyboardSelecting) { const selRange = sel.getRangeAt(0).cloneRange() const backward = selectionIsBackward(sel) if (!backward) selRange.collapse()