From: Jakub Vrana Date: Fri, 21 Mar 2025 22:10:44 +0000 (+0100) Subject: Ctrl+click in select moves the cursor in modern browsers X-Git-Tag: v5.1.0~63 X-Git-Url: https://git.joonet.de/?a=commitdiff_plain;h=711f41d05bd10aa42912ea27621555a2fa0bd9c8;p=adminer.git Ctrl+click in select moves the cursor in modern browsers --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d94e604..846e89a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Adminer dev - Confirm before exiting edited edit form - Display collation at table structure if different from table +- Ctrl+click in select moves the cursor in modern browsers - PostgreSQL: Display auto_increment of inserted rows - PostgreSQL: Display description of system variables - PostgreSQL: Avoid warning about crdb_version (bug #924, regression from 5.0.5) diff --git a/adminer/static/functions.js b/adminer/static/functions.js index 8bd450dc..cf3a4b8f 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -715,7 +715,7 @@ function selectClick(event, text, warning) { } }; - let pos = event.rangeOffset; + const pos = getSelection().anchorOffset; let value = (td.firstChild && td.firstChild.alt) || td.textContent || td.innerText; const tdStyle = window.getComputedStyle(td, null); @@ -731,14 +731,6 @@ function selectClick(event, text, warning) { if (qsa('i', td).length) { // - NULL value = ''; } - if (document.selection) { - const range = document.selection.createRange(); - range.moveToPoint(event.clientX, event.clientY); - const range2 = range.duplicate(); - range2.moveToElementText(td); - range2.setEndPoint('EndToEnd', range); - pos = range2.text.length; - } td.innerHTML = ''; td.appendChild(input); setupSubmitHighlight(td); @@ -755,11 +747,6 @@ function selectClick(event, text, warning) { input.name = td.id; input.selectionStart = pos; input.selectionEnd = pos; - if (document.selection) { - const range = document.selection.createRange(); - range.moveEnd('character', -input.value.length + pos); - range.select(); - } return true; }