ui.js: Allow to disable scrolling in method `focusElement`

This commit is contained in:
Johannes Meyer 2021-11-02 16:23:46 +01:00
parent 1c9986be72
commit f734d28060
1 changed files with 7 additions and 2 deletions

View File

@ -145,10 +145,15 @@
*
* @param {string} element The name or id of the element to focus
* @param {object} [$container] The container containing the element
* @param {boolean} [scroll] Whether the viewport should be scrolled to the focused element
*/
focusElement: function(element, $container) {
focusElement: function(element, $container, scroll) {
var $element = element;
if (typeof scroll === 'undefined') {
scroll = true;
}
if (typeof element === 'string') {
if ($container && $container.length) {
$element = $container.find('#' + element);
@ -175,7 +180,7 @@
$element[0].focus();
if ($container && $container.length) {
if (scroll && $container && $container.length) {
if (! $container.is('.container')) {
$container = $container.closest('.container');
}