From a19a0fa9f329354a434f87150756ec265faf35ea Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 29 Jul 2024 18:04:35 +0000 Subject: [PATCH] fix modal wordwrap in firefox; with overflow:auto, firefox picks the div-width before estimating the height, causing it to undershoot by the scrollbar width and then messing up the text alignment fix: conditionally set overflow-y:scroll using js --- copyparty/web/ui.css | 6 +++++- copyparty/web/util.js | 23 +++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/copyparty/web/ui.css b/copyparty/web/ui.css index 8cf930f7..9afebe5c 100644 --- a/copyparty/web/ui.css +++ b/copyparty/web/ui.css @@ -265,7 +265,11 @@ html.y #tth { box-shadow: 0 .3em 3em rgba(0,0,0,0.5); max-width: 50em; max-height: 30em; - overflow: auto; + overflow-x: auto; + overflow-y: scroll; +} +#modalc.yk { + overflow-y: auto; } #modalc td { text-align: unset; diff --git a/copyparty/web/util.js b/copyparty/web/util.js index 5ef748e5..953128ac 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -1536,6 +1536,7 @@ var modal = (function () { var r = {}, q = [], o = null, + scrolling = null, cb_up = null, cb_ok = null, cb_ng = null, @@ -1579,6 +1580,7 @@ var modal = (function () { document.addEventListener('focus', onfocus); document.addEventListener('selectionchange', onselch); + timer.add(scrollchk, 1); timer.add(onfocus); if (cb_up) setTimeout(cb_up, 1); @@ -1586,6 +1588,8 @@ var modal = (function () { r.hide = function () { timer.rm(onfocus); + timer.rm(scrollchk); + scrolling = null; try { ebi('modal-ok').removeEventListener('blur', onblur); } @@ -1604,13 +1608,28 @@ var modal = (function () { r.hide(); if (cb_ok) cb_ok(v); - } + }; var ng = function (e) { ev(e); r.hide(); if (cb_ng) cb_ng(null); - } + }; + + var scrollchk = function () { + if (scrolling === true) + return; + + var o = ebi('modalc'), + vis = o.offsetHeight, + all = o.scrollHeight, + nsc = 8 + vis < all; + + if (scrolling !== nsc) + clmod(o, 'yk', !nsc); + + scrolling = nsc; + }; var onselch = function () { try {