Skip to content

Commit

Permalink
TASK: instantly focus node when navigating from PageTree
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaip committed Mar 7, 2018
1 parent e2fd121 commit b2779e4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions Classes/Neos/Neos/Ui/Fusion/Helper/NodeInfoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function renderNode(NodeInterface $node, ControllerContext $controllerCon
'name' => $node->getName(),
'identifier' => $node->getIdentifier(),
'nodeType' => $node->getNodeType()->getName(),
'isFullyLoaded' => !$omitMostPropertiesForTreeState,
'properties' => $omitMostPropertiesForTreeState ? [
// if we are only rendering the tree state, ensure _isHidden is sent to hidden nodes are correctly shown in the tree.
'_hidden' => $node->isHidden()
Expand Down
8 changes: 6 additions & 2 deletions packages/neos-ui/src/Containers/LeftSideBar/NodeTree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,18 @@ export default class NodeTree extends PureComponent {
focus(contextPath);
}

handleClick = src => {
const {setActiveContentCanvasSrc, requestScrollIntoView} = this.props;
handleClick = (src, contextPath) => {
const {setActiveContentCanvasSrc, setActiveContentCanvasContextPath, requestScrollIntoView} = this.props;
// Set a flag that will imperatively tell ContentCanvas to scroll to focused node
if (requestScrollIntoView) {
requestScrollIntoView(true);
}
if (setActiveContentCanvasSrc) {
setActiveContentCanvasSrc(src);
}
if (setActiveContentCanvasContextPath) {
setActiveContentCanvasContextPath(contextPath);
}
}

handleDrag = node => {
Expand Down Expand Up @@ -104,6 +107,7 @@ export const PageTree = connect(state => ({
toggle: actions.UI.PageTree.toggle,
focus: actions.UI.PageTree.focus,
setActiveContentCanvasSrc: actions.UI.ContentCanvas.setSrc,
setActiveContentCanvasContextPath: actions.UI.ContentCanvas.setContextPath,
moveNode: actions.CR.Nodes.move,
requestScrollIntoView: null
})(NodeTree);
Expand Down
10 changes: 4 additions & 6 deletions packages/neos-ui/src/Containers/RightSideBar/Inspector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import I18n from '@neos-project/neos-ui-i18n';
import Bar from '@neos-project/react-ui-components/src/Bar/';
import Button from '@neos-project/react-ui-components/src/Button/';
import Tabs from '@neos-project/react-ui-components/src/Tabs/';
import Icon from '@neos-project/react-ui-components/src/Icon/';
import Immutable from 'immutable';
import debounce from 'lodash.debounce';

Expand All @@ -32,7 +33,6 @@ import style from './style.css';

return {
focusedNode: selectors.CR.Nodes.focusedSelector(state),
node: selectors.CR.Nodes.focusedSelector(state),
isApplyDisabled: isApplyDisabledSelector(state),
transientValues: selectors.UI.Inspector.transientValues(state),
isDiscardDisabled: selectors.UI.Inspector.isDiscardDisabledSelector(state),
Expand All @@ -54,7 +54,6 @@ export default class Inspector extends PureComponent {
i18nRegistry: PropTypes.object.isRequired,

focusedNode: PropTypes.object,
node: PropTypes.object.isRequired,
isApplyDisabled: PropTypes.bool,
isDiscardDisabled: PropTypes.bool,
shouldShowUnappliedChangesOverlay: PropTypes.bool,
Expand Down Expand Up @@ -195,13 +194,12 @@ export default class Inspector extends PureComponent {
}

renderFallback() {
return (<div>...</div>);
return (<div className={style.loader}><div><Icon icon="spinner" spin={true} size="big" /></div></div>);
}

render() {
const {
focusedNode,
node,
commit,
isApplyDisabled,
isDiscardDisabled,
Expand All @@ -210,7 +208,7 @@ export default class Inspector extends PureComponent {
i18nRegistry
} = this.props;

if (!focusedNode) {
if (!focusedNode || !$get('isFullyLoaded', focusedNode)) {
return this.renderFallback();
}

Expand Down Expand Up @@ -256,7 +254,7 @@ export default class Inspector extends PureComponent {
groups={$get('groups', tab)}
tooltip={i18nRegistry.translate($get('label', tab))}
renderSecondaryInspector={this.renderSecondaryInspector}
node={node}
node={focusedNode}
commit={commit}
/>);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@
width: var(--size-SidebarWidth);
}
}
.loader {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}

0 comments on commit b2779e4

Please sign in to comment.