Fix modal popups with no input elements

https://github.com/cryptpad/cryptpad/issues/1532
https://github.com/cryptpad/cryptpad/issues/1533
This commit is contained in:
Wolfgang Ginolas 2024-06-26 09:36:42 +02:00
parent ef9c79db9f
commit ac02885bfa

View File

@ -580,6 +580,12 @@ define([
let addTabListener = frame => {
// find focusable elements
let modalElements = $(frame).find('a, button, input, [tabindex]:not([tabindex="-1"]), textarea').filter(':visible').filter(':not(:disabled)');
if (modalElements.length === 0) {
// there are no focusable elements -> nothing to do for us here
return;
}
// intialize with focus on first element
modalElements[0].focus();