From 5d97e06f33ea2628ae96192868b2c5cf299a8976 Mon Sep 17 00:00:00 2001 From: Dmitri Pisarev Date: Thu, 22 Mar 2018 10:16:07 +0300 Subject: [PATCH] BUGFIX: fix CKE toolbar for properties of documentNode --- .../neos-ui-guest-frame/src/initializeGuestFrame.js | 1 + packages/neos-ui-redux-store/src/CR/Nodes/index.js | 10 +++++++++- .../neos-ui-redux-store/src/UI/ContentCanvas/index.js | 9 +++++++-- .../neos-ui/src/Containers/SecondaryToolbar/index.js | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/neos-ui-guest-frame/src/initializeGuestFrame.js b/packages/neos-ui-guest-frame/src/initializeGuestFrame.js index 9fb8792e56..be52a87fe2 100644 --- a/packages/neos-ui-guest-frame/src/initializeGuestFrame.js +++ b/packages/neos-ui-guest-frame/src/initializeGuestFrame.js @@ -84,6 +84,7 @@ export default ({globalRegistry, store}) => function * initializeGuestFrame() { actions.CR.Nodes.focus(contextPath, fusionPath) ); } else { + store.dispatch(actions.UI.ContentCanvas.setCurrentlyEditedPropertyName('')); store.dispatch( actions.CR.Nodes.unFocus() ); diff --git a/packages/neos-ui-redux-store/src/CR/Nodes/index.js b/packages/neos-ui-redux-store/src/CR/Nodes/index.js index eee029bae0..cb653ab173 100644 --- a/packages/neos-ui-redux-store/src/CR/Nodes/index.js +++ b/packages/neos-ui-redux-store/src/CR/Nodes/index.js @@ -306,7 +306,15 @@ export const reducer = handleActions({ ) )), ), - [FOCUS]: ({contextPath, fusionPath}) => $set('cr.nodes.focused', new Map({contextPath, fusionPath})), + [FOCUS]: ({contextPath, fusionPath}) => state => $all( + $set('cr.nodes.focused', new Map({contextPath, fusionPath})), + // Set currentlyEditedPropertyName to currentlyEditedPropertyNameIntermediate and clear out currentlyEditedPropertyNameIntermediate + // This is needed because SET_CURRENTLY_EDITED_PROPERTY_NAME if fired before SET_FOCUS, but we still want to clear out currentlyEditedPropertyName + // when SET_FOCUS is triggered not from inline + $set('ui.contentCanvas.currentlyEditedPropertyName', $get('ui.contentCanvas.currentlyEditedPropertyNameIntermediate', state)), + $set('ui.contentCanvas.currentlyEditedPropertyNameIntermediate', ''), + state + ), [UNFOCUS]: () => $set('cr.nodes.focused', new Map({ contextPath: '', fusionPath: '' diff --git a/packages/neos-ui-redux-store/src/UI/ContentCanvas/index.js b/packages/neos-ui-redux-store/src/UI/ContentCanvas/index.js index 83988f3f93..50ca289924 100644 --- a/packages/neos-ui-redux-store/src/UI/ContentCanvas/index.js +++ b/packages/neos-ui-redux-store/src/UI/ContentCanvas/index.js @@ -1,6 +1,6 @@ import {createAction} from 'redux-actions'; import {Map} from 'immutable'; -import {$set, $get} from 'plow-js'; +import {$set, $get, $all} from 'plow-js'; import {handleActions} from '@neos-project/utils-redux'; @@ -78,6 +78,7 @@ export const reducer = handleActions({ src: $get('ui.contentCanvas.src', state) || '', formattingUnderCursor: new Map(), currentlyEditedPropertyName: '', + currentlyEditedPropertyNameIntermediate: '', isLoading: true, focusedProperty: '', backgroundColor: $get('ui.contentCanvas.backgroundColor', state), @@ -108,7 +109,11 @@ export const reducer = handleActions({ [SET_PREVIEW_URL]: ({previewUrl}) => $set('ui.contentCanvas.previewUrl', previewUrl), [SET_SRC]: ({src}) => $set('ui.contentCanvas.src', src), [FORMATTING_UNDER_CURSOR]: ({formatting}) => $set('ui.contentCanvas.formattingUnderCursor', new Map(formatting)), - [SET_CURRENTLY_EDITED_PROPERTY_NAME]: ({propertyName}) => $set('ui.contentCanvas.currentlyEditedPropertyName', propertyName), + [SET_CURRENTLY_EDITED_PROPERTY_NAME]: ({propertyName}) => $all( + $set('ui.contentCanvas.currentlyEditedPropertyName', propertyName), + // See SET_FOCUS why it's needed + $set('ui.contentCanvas.currentlyEditedPropertyNameIntermediate', propertyName) + ), [STOP_LOADING]: () => $set('ui.contentCanvas.isLoading', false), [START_LOADING]: () => $set('ui.contentCanvas.isLoading', true), [REQUEST_SCROLL_INTO_VIEW]: activate => $set('ui.contentCanvas.shouldScrollIntoView', activate), diff --git a/packages/neos-ui/src/Containers/SecondaryToolbar/index.js b/packages/neos-ui/src/Containers/SecondaryToolbar/index.js index 0a40fbb6a7..b2d008d6f1 100644 --- a/packages/neos-ui/src/Containers/SecondaryToolbar/index.js +++ b/packages/neos-ui/src/Containers/SecondaryToolbar/index.js @@ -42,7 +42,7 @@ export default class SecondaryToolbar extends PureComponent { const {containerRegistry, currentlyEditedPropertyName, hasFocusedContentNode} = this.props; const DimensionSwitcher = containerRegistry.get('SecondaryToolbar/DimensionSwitcher'); - if (!hasFocusedContentNode) { + if (!hasFocusedContentNode && !currentlyEditedPropertyName) { return DimensionSwitcher; }