Skip to content

Commit e5b990c

Browse files
committed
BUGFIX: fix hover on toggle icon not changing color to blue, add hover effect for nodes in nodeTress, add function to collapse childrens of node via shift press on toggle icon 7.3
1 parent 32f8dc5 commit e5b990c

File tree

5 files changed

+49
-13
lines changed

5 files changed

+49
-13
lines changed

packages/neos-ui-redux-store/src/UI/ContentTree/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export enum actionTypes {
3333
SET_AS_LOADED = '@neos/neos-ui/UI/ContentTree/SET_AS_LOADED',
3434
}
3535

36-
const toggle = (contextPath: NodeContextPath) => createAction(actionTypes.TOGGLE, contextPath);
36+
const toggle = (contextPath: NodeContextPath, collapseChildren: boolean, childrenContextPaths: NodeContextPath[], childrenCollapsedByDefault: boolean) => createAction(actionTypes.TOGGLE, {contextPath, collapseChildren, childrenContextPaths, childrenCollapsedByDefault});
3737
const startLoading = () => createAction(actionTypes.START_LOADING);
3838
const stopLoading = () => createAction(actionTypes.STOP_LOADING);
3939
const reloadTree = () => createAction(actionTypes.RELOAD_TREE);
@@ -70,8 +70,16 @@ export const reducer = (state: State = defaultState, action: InitAction | Action
7070
break;
7171
}
7272
case actionTypes.TOGGLE: {
73-
const contextPath = action.payload;
74-
if (draft.toggled.includes(contextPath)) {
73+
const {contextPath, collapseChildren, childrenContextPaths, childrenCollapsedByDefault} = action.payload;
74+
if (collapseChildren) {
75+
childrenContextPaths.forEach(child => {
76+
if (!childrenCollapsedByDefault && !draft.toggled.includes(child)) {
77+
draft.toggled.push(child);
78+
} else if (childrenCollapsedByDefault && draft.toggled.includes(child)) {
79+
draft.toggled = draft.toggled.filter(i => i !== child);
80+
}
81+
})
82+
} else if (draft.toggled.includes(contextPath)) {
7583
draft.toggled = draft.toggled.filter(i => i !== contextPath);
7684
} else {
7785
draft.toggled.push(contextPath);

packages/neos-ui-redux-store/src/UI/PageTree/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export enum actionTypes {
4444
}
4545

4646
const focus = (contextPath: NodeContextPath, _: undefined, selectionMode: SelectionModeTypes = SelectionModeTypes.SINGLE_SELECT) => createAction(actionTypes.FOCUS, {contextPath, selectionMode});
47-
const toggle = (contextPath: NodeContextPath) => createAction(actionTypes.TOGGLE, {contextPath});
47+
const toggle = (contextPath: NodeContextPath, collapseChildren: boolean, childrenContextPaths: NodeContextPath[], childrenCollapsedByDefault: boolean) => createAction(actionTypes.TOGGLE, {contextPath, collapseChildren, childrenContextPaths, childrenCollapsedByDefault});
4848
const invalidate = (contextPath: NodeContextPath) => createAction(actionTypes.INVALIDATE, {contextPath});
4949
const requestChildren = (contextPath: NodeContextPath, {unCollapse = true, activate = false} = {}) => createAction(actionTypes.REQUEST_CHILDREN, {contextPath, opts: {unCollapse, activate}});
5050
const setAsLoading = (contextPath: NodeContextPath) => createAction(actionTypes.SET_AS_LOADING, {contextPath});
@@ -96,8 +96,16 @@ export const reducer = (state: State = defaultState, action: InitAction | Action
9696
break;
9797
}
9898
case actionTypes.TOGGLE: {
99-
const contextPath = action.payload.contextPath;
100-
if (draft.toggled.includes(contextPath)) {
99+
const {contextPath, collapseChildren, childrenContextPaths, childrenCollapsedByDefault} = action.payload;
100+
if (collapseChildren) {
101+
childrenContextPaths.forEach(child => {
102+
if (!childrenCollapsedByDefault && !draft.toggled.includes(child)) {
103+
draft.toggled.push(child);
104+
} else if (childrenCollapsedByDefault && draft.toggled.includes(child)) {
105+
draft.toggled = draft.toggled.filter(i => i !== child);
106+
}
107+
})
108+
} else if (draft.toggled.includes(contextPath)) {
101109
draft.toggled = draft.toggled.filter(i => i !== contextPath);
102110
} else {
103111
draft.toggled.push(contextPath);

packages/neos-ui/src/Containers/LeftSideBar/NodeTree/Node/index.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,23 @@ export default class Node extends PureComponent {
355355
);
356356
}
357357

358-
handleNodeToggle = () => {
359-
const {node, onNodeToggle} = this.props;
360-
onNodeToggle(node.contextPath);
358+
handleNodeToggle = (e) => {
359+
const {node, onNodeToggle, childNodes, isContentTreeNode, loadingDepth, rootNode} = this.props;
360+
const children = [...childNodes];
361+
const childrenLoaded = children[0] !== undefined;
362+
const childrenContextPaths = [];
363+
let childrenCollapsedByDefault = false;
364+
365+
if (childrenLoaded) {
366+
childrenCollapsedByDefault = loadingDepth === 0 ? false : (node.depth + 1) - rootNode.depth >= loadingDepth;
367+
const childrenWithChildren = children.filter((child) => child.children.length > (isContentTreeNode ? 0 : 1));
368+
369+
childrenWithChildren.forEach(child => {
370+
childrenContextPaths.push(child.contextPath);
371+
})
372+
}
373+
374+
onNodeToggle(node.contextPath, e.shiftKey, childrenContextPaths, childrenCollapsedByDefault);
361375
}
362376

363377
handleNodeClick = e => {

packages/neos-ui/src/Containers/LeftSideBar/NodeTree/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ export default class NodeTree extends PureComponent {
3939
currentlyDraggedNodes: []
4040
};
4141

42-
handleToggle = contextPath => {
42+
handleToggle = (contextPath, collapseChildren, childrenContextPaths, childrenCollapsedByDefault) => {
4343
const {toggle} = this.props;
44-
45-
toggle(contextPath);
44+
toggle(contextPath, collapseChildren, childrenContextPaths, childrenCollapsedByDefault);
4645
}
4746

4847
handleFocus = (contextPath, metaKeyPressed, altKeyPressed, shiftKeyPressed) => {

packages/react-ui-components/src/Tree/node.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
cursor: pointer;
2020

21-
&:hover {
21+
&:hover > svg {
2222
color: var(--colors-PrimaryBlue);
2323
}
2424
}
@@ -43,6 +43,11 @@
4343
display: inline-block;
4444
position: absolute;
4545
text-align: center;
46+
47+
.header:hover & > svg,
48+
.header__data--isActive & > svg {
49+
color: var(--colors-PrimaryBlue);
50+
}
4651
}
4752

4853
.header__data {
@@ -100,6 +105,7 @@
100105
composes: reset from './../reset.css';
101106
margin-left: 2em;
102107

108+
.header:hover &,
103109
.header__data--isActive & {
104110
color: var(--colors-PrimaryBlue);
105111
}
@@ -119,6 +125,7 @@
119125

120126
[data-is-drag-happening] & {
121127
visibility: visible;
128+
height: 5px;
122129
}
123130
}
124131
.dropTarget--before {

0 commit comments

Comments
 (0)