Skip to content

Commit a19a0fa

Browse files
committed
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
1 parent 9bb6e0d commit a19a0fa

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

copyparty/web/ui.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,11 @@ html.y #tth {
265265
box-shadow: 0 .3em 3em rgba(0,0,0,0.5);
266266
max-width: 50em;
267267
max-height: 30em;
268-
overflow: auto;
268+
overflow-x: auto;
269+
overflow-y: scroll;
270+
}
271+
#modalc.yk {
272+
overflow-y: auto;
269273
}
270274
#modalc td {
271275
text-align: unset;

copyparty/web/util.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,7 @@ var modal = (function () {
15361536
var r = {},
15371537
q = [],
15381538
o = null,
1539+
scrolling = null,
15391540
cb_up = null,
15401541
cb_ok = null,
15411542
cb_ng = null,
@@ -1579,13 +1580,16 @@ var modal = (function () {
15791580

15801581
document.addEventListener('focus', onfocus);
15811582
document.addEventListener('selectionchange', onselch);
1583+
timer.add(scrollchk, 1);
15821584
timer.add(onfocus);
15831585
if (cb_up)
15841586
setTimeout(cb_up, 1);
15851587
};
15861588

15871589
r.hide = function () {
15881590
timer.rm(onfocus);
1591+
timer.rm(scrollchk);
1592+
scrolling = null;
15891593
try {
15901594
ebi('modal-ok').removeEventListener('blur', onblur);
15911595
}
@@ -1604,13 +1608,28 @@ var modal = (function () {
16041608
r.hide();
16051609
if (cb_ok)
16061610
cb_ok(v);
1607-
}
1611+
};
16081612
var ng = function (e) {
16091613
ev(e);
16101614
r.hide();
16111615
if (cb_ng)
16121616
cb_ng(null);
1613-
}
1617+
};
1618+
1619+
var scrollchk = function () {
1620+
if (scrolling === true)
1621+
return;
1622+
1623+
var o = ebi('modalc'),
1624+
vis = o.offsetHeight,
1625+
all = o.scrollHeight,
1626+
nsc = 8 + vis < all;
1627+
1628+
if (scrolling !== nsc)
1629+
clmod(o, 'yk', !nsc);
1630+
1631+
scrolling = nsc;
1632+
};
16141633

16151634
var onselch = function () {
16161635
try {

0 commit comments

Comments
 (0)