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
This commit is contained in:
John Factotum
2024-12-12 09:35:33 +08:00
parent cc2882ff39
commit 63a5dbf3e3
+1 -1
View File
@@ -596,7 +596,7 @@ export class Paginator extends HTMLElement {
if (!sel.rangeCount) return if (!sel.rangeCount) return
if (isPointerSelecting && sel.type === 'Range') if (isPointerSelecting && sel.type === 'Range')
checkPointerSelection(range, sel) checkPointerSelection(range, sel)
else if (isKeyboardSelecting || sel.type === 'Caret') { else if (isKeyboardSelecting) {
const selRange = sel.getRangeAt(0).cloneRange() const selRange = sel.getRangeAt(0).cloneRange()
const backward = selectionIsBackward(sel) const backward = selectionIsBackward(sel)
if (!backward) selRange.collapse() if (!backward) selRange.collapse()