Add more sophisticated fix for keeping the focus after an autorefresh

fixes #8350
This commit is contained in:
Johannes Meyer 2015-02-17 09:24:29 +01:00
parent ea57e7a786
commit 3dce0e434a
1 changed files with 4 additions and 2 deletions

View File

@ -675,7 +675,6 @@
// Container update happens here
var scrollPos = false;
var self = this;
var origFocus = self.icinga.utils.getDomPath(document.activeElement);
var containerId = $container.attr('id');
if (typeof containerId !== 'undefined') {
if (autorefresh) {
@ -684,6 +683,9 @@
scrollPos = 0;
}
}
if (autorefresh && $.contains($container[0], document.activeElement)) {
var origFocus = self.icinga.utils.getDomPath(document.activeElement);
}
$container.trigger('beforerender');
@ -740,7 +742,7 @@
}
this.icinga.ui.assignUniqueContainerIds();
if (origFocus.length == origFocus[0] !== '') {
if (origFocus && origFocus.length > 0 && origFocus[0] !== '') {
setTimeout(function() {
$(self.icinga.utils.getElementByDomPath(origFocus)).focus();
}, 0);