Browse Source

Merge pull request #23005 from abpframework/modal-manager

Place the cursor at the end after the element receives focus.
pull/23033/head
Yağmur Çelik 1 year ago
committed by GitHub
parent
commit
071d6bb209
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 12
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js

12
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js

@ -104,6 +104,7 @@ $.validator.defaults.ignore = ''; //TODO: Would be better if we can apply only f
}
}
var focusElement = null;
if (!options.focusElement) {
//focuses first element if it's a typeable input.
var $firstVisibleInput = _$modal.find('input:not([type=hidden]):first');
@ -120,11 +121,18 @@ $.validator.defaults.ignore = ''; //TODO: Would be better if we can apply only f
}
$firstVisibleInput.focus();
focusElement = $firstVisibleInput;
} else if (typeof options.focusElement === 'function') {
var focusElement = options.focusElement();
focusElement = options.focusElement();
focusElement.focus();
} else if (typeof options.focusElement === 'string') {
$(options.focusElement).focus();
focusElement = $(options.focusElement);
focusElement.focus();
}
if (focusElement && $(focusElement).is('input')) {
var value = focusElement.val();
focusElement[0].setSelectionRange(value.length, value.length);
}
});

Loading…
Cancel
Save