From edef2b1a3d02febbb7362c1600ae96145b902260 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 8f751ac6..81ca0bde 100644 --- a/adminer/static/default.css +++ b/adminer/static/default.css @@ -24,6 +24,7 @@ tbody tr:hover td, tbody tr:hover th { background: #eee; } pre { margin: 1em 0 0; } pre, textarea { font: 100%/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 d885bd22..14252b65 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -708,9 +708,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 () { -- 2.39.5