From 2e5359b7eee39a376092a7b1bf4d35f98e8a0fbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Mon, 20 May 2019 15:47:58 +0200 Subject: [PATCH] Lose focus on any active element when clicked into empty space in newsletter [MAILPOET-1811] --- assets/js/src/newsletter_editor/blocks/container.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/assets/js/src/newsletter_editor/blocks/container.js b/assets/js/src/newsletter_editor/blocks/container.js index 12643d4db4..7abaf2e8aa 100644 --- a/assets/js/src/newsletter_editor/blocks/container.js +++ b/assets/js/src/newsletter_editor/blocks/container.js @@ -79,6 +79,9 @@ Module.ContainerBlockModel = base.BlockModel.extend({ Module.ContainerBlocksView = Marionette.CollectionView.extend({ className: 'mailpoet_container', + events: { + click: 'removeFocusFromAnyActiveElement', + }, childView: function (model) { return App.getBlockTypeView(model.get('type')); }, @@ -102,6 +105,15 @@ Module.ContainerBlocksView = Marionette.CollectionView.extend({ onChildviewResizeStop: function onChildviewResizeStart(event) { this.triggerMethod('resizeStop', event); }, + removeFocusFromAnyActiveElement: function removeFocusFromAnyActiveElement(event) { + if (!event || !event.target) { + return; + } + if (event.target.className.indexOf('mailpoet_container_horizontal') === -1) { + return; + } + document.activeElement.blur(); + }, }); Module.ContainerBlockView = base.BlockView.extend({