From 4c23d7fec9f2c66b1f66c2757731bd0ecf63b4bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Wed, 8 May 2019 15:09:01 +0200 Subject: [PATCH] removed properties, replaced with a getter method. --- .../components/application/umbsearch.directive.js | 2 +- .../src/common/services/focus.service.js | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/application/umbsearch.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/application/umbsearch.directive.js index 30551bff09..91eb077ba3 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/application/umbsearch.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/application/umbsearch.directive.js @@ -27,7 +27,7 @@ vm.focusSearch = focusSearch; //we need to capture the focus before this element is initialized. - vm.focusBeforeOpening = focusService.lastKnownFocus; + vm.focusBeforeOpening = focusService.getLastKnownFocus(); function onInit() { vm.searchQuery = ""; diff --git a/src/Umbraco.Web.UI.Client/src/common/services/focus.service.js b/src/Umbraco.Web.UI.Client/src/common/services/focus.service.js index da381a6cc4..ebaff7eb89 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/focus.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/focus.service.js @@ -13,14 +13,17 @@ function focusService() { + var currentFocus = null; + var lastKnownFocus = null; + + function focusInApp(e) { - service.currentFocus = e.target; + currentFocus = e.target; } document.addEventListener('focusin', focusInApp); var service = { - currentFocus: null, /** * @ngdoc property @@ -32,7 +35,9 @@ * This variable is avaiable for directives that are not able to figure out the focused element on init, and there this service will help remembering it untill the directive is initialized. * */ - lastKnownFocus: null, + getLastKnownFocus: function() { + return lastKnownFocus; + }, /** * @ngdoc function @@ -45,7 +50,7 @@ * */ rememberFocus: function() { - service.lastKnownFocus = service.currentFocus; + lastKnownFocus = currentFocus; }, /** @@ -59,7 +64,7 @@ * */ setLastKnownFocus: function(element) { - service.lastKnownFocus = element; + lastKnownFocus = element; } };