From b6058368d32ea831361b4bb22f4547a3517dd447 Mon Sep 17 00:00:00 2001 From: Peter Knut Date: Thu, 3 Oct 2024 23:31:27 +0200 Subject: [PATCH] Fix the width of inline edit field --- adminer/static/default.css | 1 + adminer/static/functions.js | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/adminer/static/default.css b/adminer/static/default.css index 7875be1b..e52fc067 100644 --- a/adminer/static/default.css +++ b/adminer/static/default.css @@ -25,6 +25,7 @@ pre { margin: 1em 0 0; } pre code { display: block; font-size: 100%; } pre, textarea { font: 110%/1.25 monospace; } pre.jush { background: #fff; } +input, textarea { box-sizing: border-box; } input, select { vertical-align: middle; } input.default { box-shadow: 1px 1px 1px #777; } input.required { box-shadow: 1px 1px 1px red; } diff --git a/adminer/static/functions.js b/adminer/static/functions.js index 19c1ee06..c5d8107f 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -716,9 +716,13 @@ function selectClick(event, text, warning) { td.innerHTML = original; } }; - var pos = event.rangeOffset; - var value = (td.firstChild && td.firstChild.alt) || td.textContent || td.innerText; - input.style.width = Math.max(td.clientWidth - 14, 20) + 'px'; // 14 = 2 * (td.border + td.padding + input.border) + + let pos = event.rangeOffset; + let value = (td.firstChild && td.firstChild.alt) || td.textContent || td.innerText; + const tdStyle = window.getComputedStyle(td, null); + + input.style.width = Math.max(td.clientWidth - parseFloat(tdStyle.paddingLeft) - parseFloat(tdStyle.paddingRight), 20) + 'px'; + if (text) { var rows = 1; value.replace(/\n/g, function () {