From 040ebfe9dd7d7053ccf4393f8a83c11fc3866b69 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Tue, 14 May 2019 21:51:53 +0200 Subject: [PATCH] Add auto-focus to the default action in overlay dialogs --- .../directives/components/buttons/umbbutton.directive.js | 3 ++- .../directives/components/forms/umbautofocus.directive.js | 8 +++++--- .../components/overlays/umboverlay.directive.js | 5 ++--- .../src/views/components/buttons/umb-button.html | 4 ++-- .../src/views/components/overlays/umb-overlay.html | 6 ++++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/buttons/umbbutton.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/buttons/umbbutton.directive.js index 83904bd0369d..f026a05c45ed 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/buttons/umbbutton.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/buttons/umbbutton.directive.js @@ -95,7 +95,8 @@ Use this directive to render an umbraco button. The directive can be used to gen size: "@?", alias: "@?", addEllipsis: "@?", - showCaret: "@?" + showCaret: "@?", + autoFocus: "@?" } }); diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbautofocus.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbautofocus.directive.js index 6fcdd99001ec..eb3503f799b3 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbautofocus.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbautofocus.directive.js @@ -9,8 +9,10 @@ angular.module("umbraco.directives") } }; - $timeout(function() { - update(); - }); + if (attr.umbAutoFocus !== "false") { + $timeout(function() { + update(); + }); + } }; }); diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/overlays/umboverlay.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/overlays/umboverlay.directive.js index 8c32d93c01d7..0135abd97c57 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/overlays/umboverlay.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/overlays/umboverlay.directive.js @@ -311,9 +311,8 @@ Opens an overlay to show a custom YSOD.
var submitOnEnter = document.activeElement.hasAttribute("overlay-submit-on-enter"); var submitOnEnterValue = submitOnEnter ? document.activeElement.getAttribute("overlay-submit-on-enter") : ""; - if(clickableElements.indexOf(activeElementType) === 0) { - document.activeElement.trigger("click"); - event.preventDefault(); + if(clickableElements.indexOf(activeElementType) >= 0) { + // don't do anything, let the browser Enter key handle this } else if(activeElementType === "TEXTAREA" && !submitOnEnter) { diff --git a/src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-button.html b/src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-button.html index dcad858781db..8163b2807be0 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-button.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-button.html @@ -15,7 +15,7 @@ - -