From 73e00ca51e0f73fcb4876f97f4001e820a93f954 Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Wed, 4 Jun 2025 14:06:37 +0800 Subject: [PATCH] Place the cursor at the end after the element receives focus. --- .../bootstrap/modal-manager.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js index d232dbd28a..f8c9543e0d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js +++ b/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); } });