From: Ardis Lu Date: Mon, 22 Jul 2024 03:03:25 +0000 (-0700) Subject: Fix Chrome triple click over-selecting X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=8024f398d17137b6b0288af5a0d7e7c7a408aee1;p=event-hashes Fix Chrome triple click over-selecting Otherwise, triple click will select a trailing element which results in a trailing tab or newline when pasted. --- 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); + }; + });