From 8024f398d17137b6b0288af5a0d7e7c7a408aee1 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sun, 21 Jul 2024 20:03:25 -0700 Subject: [PATCH] Fix Chrome triple click over-selecting Otherwise, triple click will select a trailing element which results in a trailing tab or newline when pasted. --- index.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/index.html b/index.html index 5e5e07c..f2aa443 100644 --- a/index.html +++ b/index.html @@ -466,6 +466,18 @@ textarea.focus(); } }); + + // Fix Chrome selecting trailing element on triple (or quad) click, resulting in a trailing tab or newline + // when copying text from the table. + addEventListener('click', e => { + if (e.detail >= 3 && table.contains(e.target)) { + const selection = getSelection(); + const range = selection.getRangeAt(0); + const textNode = e.target.firstChild; + range.setStart(textNode, 0); + range.setEnd(textNode, textNode.length); + }; + }); -- 2.47.3