From 56499cae5d9f5b1ac8fd08626ff68374cd1ea807 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Wed, 23 May 2018 14:10:24 +0100 Subject: [PATCH] Koenig - Fixed card creation from plus menu refs https://github.com/TryGhost/Ghost-Admin/commit/569a6942cd3a9c4f92c0f78e5898fab507345c50 - perform a check for a click originating on the plus menu in `{{koenig-card}}` to avoid an immediate deselection as soon as an editable card is created - removed unnecessary `.koenig-plus-menu` class in favour of `[data-kg="plus-menu"]` selector --- .../lib/koenig-editor/addon/components/koenig-card.js | 10 +++++++--- .../koenig-editor/addon/components/koenig-plus-menu.js | 7 ++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-card.js b/ghost/admin/lib/koenig-editor/addon/components/koenig-card.js index 06624cca12..540ff0e887 100644 --- a/ghost/admin/lib/koenig-editor/addon/components/koenig-card.js +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-card.js @@ -205,11 +205,15 @@ export default Component.extend({ }, // exit edit mode any time we have a click outside of the card unless it's - // a click inside one of our modals + // a click inside one of our modals or on the plus menu _handleClick({target, path}) { - let liquidDestination = element => element.closest && element.closest('.liquid-destination'); + let searchPath = function (selector) { + return element => element.closest && element.closest(selector); + }; - if (this.element.contains(target) || path.find(liquidDestination)) { + if (this.element.contains(target) + || path.find(searchPath('[data-kg="plus-menu"]')) + || path.find(searchPath('.liquid-destination'))) { return; } diff --git a/ghost/admin/lib/koenig-editor/addon/components/koenig-plus-menu.js b/ghost/admin/lib/koenig-editor/addon/components/koenig-plus-menu.js index 236bc71f33..298e79f07c 100644 --- a/ghost/admin/lib/koenig-editor/addon/components/koenig-plus-menu.js +++ b/ghost/admin/lib/koenig-editor/addon/components/koenig-plus-menu.js @@ -8,8 +8,8 @@ export default Component.extend({ layout, // public attrs - classNames: ['koenig-plus-menu', 'absolute'], - attributeBindings: ['style'], + classNames: ['absolute'], + attributeBindings: ['style', 'data-kg'], editor: null, editorRange: null, @@ -17,6 +17,7 @@ export default Component.extend({ showButton: false, showMenu: false, top: 0, + 'data-kg': 'plus-menu', // private properties _onResizeHandler: null, @@ -122,7 +123,7 @@ export default Component.extend({ // find the "top" position by grabbing the current sections // render node and querying it's bounding rect. Setting "top" - // positions the button+menu container element .koenig-plus-menu + // positions the button+menu container element [data-kg="plus-menu"] _positionMenu() { // use the cached range if available because `editorRange` may have been // lost due to clicks on the open menu