js: Enhance scroll location detection in `ui.focusElement()`

This commit is contained in:
Johannes Meyer 2019-12-13 16:13:13 +01:00
parent f5ce5d42ef
commit 63452ba250
1 changed files with 13 additions and 2 deletions

View File

@ -175,8 +175,19 @@
$element[0].focus();
if ($container && $container.length) {
$container.scrollTop(0);
$container.scrollTop($element.first().position().top);
if (! $container.is('.container')) {
$container = $container.closest('.container');
}
if ($container.css('display') === 'flex' && $container.is('.container')) {
var $controls = $container.find('.controls');
var $content = $container.find('.content');
$content.scrollTop($element.offsetTopRelativeTo($content) - $controls.outerHeight() - (
$element.outerHeight(true) - $element.innerHeight()
));
} else {
$container.scrollTop($element.first().position().top);
}
}
}
},