mirror of
https://github.com/9001/copyparty.git
synced 2025-08-19 09:52:21 -06:00
fence focus inside modals
This commit is contained in:
parent
4802f8cf07
commit
7e84f4f015
|
@ -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;
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue