diff --git a/copyparty/web/browser.css b/copyparty/web/browser.css index 8bcdd52f..09f96003 100644 --- a/copyparty/web/browser.css +++ b/copyparty/web/browser.css @@ -1013,6 +1013,8 @@ html.light #rui { #barpos, #u2conf label, #rui label, +#modal-ok, +#modal-ng, #ops { -webkit-user-select: none; -moz-user-select: none; diff --git a/copyparty/web/util.js b/copyparty/web/util.js index fc6efcfa..817d3577 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -725,11 +725,15 @@ var modal = (function () { a.onclick = ok; (ebi('modali') || a).focus(); + document.addEventListener('focus', onfocus); + timer.add(onfocus); }; r.hide = function () { - o.parentNode.removeChild(o); + timer.rm(onfocus); + document.removeEventListener('focus', onfocus); document.removeEventListener('keydown', onkey); + o.parentNode.removeChild(o); r.busy = false; setTimeout(next, 50); }; @@ -748,6 +752,17 @@ var modal = (function () { cb_ng(null); } + function onfocus(e) { + var ctr = ebi('modalc'); + if (!ctr || !ctr.contains || !document.activeElement || ctr.contains(document.activeElement)) + return; + + setTimeout(function () { + ebi('modal-ok').focus(); + }, 20); + ev(e); + } + function onkey(e) { if (e.code == 'Enter') { var a = ebi('modal-ng');