From e906808a9be56f8034d0d5332135de78e50305a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Tue, 7 May 2019 10:59:09 +0200 Subject: [PATCH] unbind keyboard shortcuts for editors when backdrop is active --- .../components/forms/hotkey.directive.js | 2 - .../overlays/umboverlay.directive.js | 3 +- .../src/common/services/editor.service.js | 51 ++++++++++++++++++- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/hotkey.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/hotkey.directive.js index 1b6fc9f4bb..8db301da55 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/hotkey.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/hotkey.directive.js @@ -49,8 +49,6 @@ angular.module("umbraco.directives") } else { element.trigger("click"); } - - keyboardService.stopPropagation() } 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 99b89bf8cf..e411be2c83 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 @@ -295,7 +295,8 @@ Opens an overlay to show a custom YSOD.
scope.closeOverLay(); }); } - + + event.stopPropagation(); event.preventDefault(); } diff --git a/src/Umbraco.Web.UI.Client/src/common/services/editor.service.js b/src/Umbraco.Web.UI.Client/src/common/services/editor.service.js index 4357caf5be..a97773f77e 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/editor.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/editor.service.js @@ -164,9 +164,22 @@ When building a custom infinite editor view you can use the same components as a "use strict"; function editorService(eventsService, keyboardService, $timeout) { - + + let editorsKeyboardShorcuts = []; var editors = []; + var isEnabled = true; + + + // events for backdrop + eventsService.on("appState.backdrop", function (name, args) { + if (args.show === true) { + blur(); + } else { + focus(); + } + }); + /** * @ngdoc method @@ -191,7 +204,43 @@ When building a custom infinite editor view you can use the same components as a function getNumberOfEditors() { return editors.length; }; + + /** + * @ngdoc method + * @name umbraco.services.editorService#blur + * @methodOf umbraco.services.editorService + * + * @description + * Method to tell editors that they are begin blurred. + */ + function blur() { + /* keyboard shortcuts will be overwritten by the new infinite editor + so we need to store the shortcuts for the current editor so they can be rebound + when the infinite editor closes + */ + unbindKeyboardShortcuts(); + isEnabled = false; + } + /** + * @ngdoc method + * @name umbraco.services.editorService#blur + * @methodOf umbraco.services.editorService + * + * @description + * Method to tell editors that they are gaining focus again. + */ + function focus() { + if(isEnabled === false) { + /* keyboard shortcuts will be overwritten by the new infinite editor + so we need to store the shortcuts for the current editor so they can be rebound + when the infinite editor closes + */ + rebindKeyboardShortcuts(); + isEnabled = true; + } + } + /** * @ngdoc method * @name umbraco.services.editorService#open