loader.js: Also preserve scroll position of `display:flex` containers
This commit is contained in:
parent
680467a1aa
commit
d6677bfb66
|
@ -1058,9 +1058,16 @@
|
||||||
activeElementPath = this.icinga.utils.getCSSPath($activeElement);
|
activeElementPath = this.icinga.utils.getCSSPath($activeElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var scrollTarget = $container;
|
||||||
if (! forceFocus && typeof containerId !== 'undefined') {
|
if (! forceFocus && typeof containerId !== 'undefined') {
|
||||||
if (autorefresh || autoSubmit) {
|
if (autorefresh || autoSubmit) {
|
||||||
scrollPos = $container.scrollTop();
|
if ($container.css('display') === 'flex') {
|
||||||
|
var $scrollableContent = $container.children('.content');
|
||||||
|
scrollPos = $scrollableContent.scrollTop();
|
||||||
|
scrollTarget = _this.icinga.utils.getCSSPath($scrollableContent);
|
||||||
|
} else {
|
||||||
|
scrollPos = $container.scrollTop();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
scrollPos = 0;
|
scrollPos = 0;
|
||||||
}
|
}
|
||||||
|
@ -1142,12 +1149,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scrollPos !== false) {
|
if (scrollPos !== false) {
|
||||||
$container.scrollTop(scrollPos);
|
var $scrollTarget = $(scrollTarget);
|
||||||
|
$scrollTarget.scrollTop(scrollPos);
|
||||||
|
|
||||||
// Fallback for browsers without support for focus({preventScroll: true})
|
// Fallback for browsers without support for focus({preventScroll: true})
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
if ($container.scrollTop() !== scrollPos) {
|
if ($scrollTarget.scrollTop() !== scrollPos) {
|
||||||
$container.scrollTop(scrollPos);
|
$scrollTarget.scrollTop(scrollPos);
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue