js: Improve rejection of autorefresh responses

Don't reject autorefreshes if an autosubmit
element is focused but not interacted with

fixes #4996
This commit is contained in:
Johannes Meyer 2024-02-06 10:59:20 +01:00
parent a48a6ebcb5
commit 6964bd19a2
1 changed files with 7 additions and 7 deletions

View File

@ -78,13 +78,13 @@
return null; return null;
} }
var origFocus = document.activeElement; const origFocus = document.activeElement;
var containerId = $container.attr('id'); const containerId = $container.attr('id');
if ($container.has(origFocus).length if ($container[0].contains(origFocus)
&& $(origFocus).length && origFocus.form
&& ! $(origFocus).hasClass('autofocus') && ! origFocus.matches(
&& $(origFocus).closest('form').length 'input[type=submit], input[type=reset], input[type=button], .autofocus, .autosubmit:not(:hover)'
&& $(origFocus).not(':input[type=button], :input[type=submit], :input[type=reset]').length )
) { ) {
this.icinga.logger.debug('Not changing content for ' + containerId + ' form has focus'); this.icinga.logger.debug('Not changing content for ' + containerId + ' form has focus');
return null; return null;