Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: fix hover on toggle icon not changing color to blue #3635

Merged
merged 6 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/neos-ui-redux-store/src/UI/ContentTree/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export enum actionTypes {
SET_AS_LOADED = '@neos/neos-ui/UI/ContentTree/SET_AS_LOADED',
}

const toggle = (contextPath: NodeContextPath) => createAction(actionTypes.TOGGLE, contextPath);
const toggle = (contextPath: NodeContextPath, collapseChildren: boolean, childrenContextPaths: NodeContextPath[], childrenCollapsedByDefault: boolean) => createAction(actionTypes.TOGGLE, {contextPath, collapseChildren, childrenContextPaths, childrenCollapsedByDefault});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⬆️ This is breaking. Plugins may rely on the signature of this action creator. Adding additional parameters will break any call-site that isn't aware of the change.

To differentiate between the two scenarios ("Toggle collapsed-state of a node" and "Collapse all children of a node"), it'd be better to have an entirely separate redux action (like collapseChildren). The handleToggle method in packages/neos-ui/src/Containers/LeftSideBar/NodeTree/Node/index.js can take care of calling one or the other depending on the given DOM event.

Besides that, as I wrote above already, I don't think that shift+leftclick is an appropriate way to capture the user's intent with regards to this action.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thank you for your elaborate review and insights. I agree, I will work on the collapsing buttons in a different PR and remove the changes from this PR when I find time for that. I was thinking of both a collapse all button (Visual Studio Code) and the shift+leftclick which I am used to from the Godot Editor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the reference to Godot :) That is indeed a very good example. I didn't know of that behavior.

const startLoading = () => createAction(actionTypes.START_LOADING);
const stopLoading = () => createAction(actionTypes.STOP_LOADING);
const reloadTree = () => createAction(actionTypes.RELOAD_TREE);
Expand Down Expand Up @@ -70,8 +70,16 @@ export const reducer = (state: State = defaultState, action: InitAction | Action
break;
}
case actionTypes.TOGGLE: {
const contextPath = action.payload;
if (draft.toggled.includes(contextPath)) {
const {contextPath, collapseChildren, childrenContextPaths, childrenCollapsedByDefault} = action.payload;
if (collapseChildren) {
childrenContextPaths.forEach(child => {
if (!childrenCollapsedByDefault && !draft.toggled.includes(child)) {
draft.toggled.push(child);
} else if (childrenCollapsedByDefault && draft.toggled.includes(child)) {
draft.toggled = draft.toggled.filter(i => i !== child);
}
});
} else if (draft.toggled.includes(contextPath)) {
draft.toggled = draft.toggled.filter(i => i !== contextPath);
} else {
draft.toggled.push(contextPath);
Expand Down
14 changes: 11 additions & 3 deletions packages/neos-ui-redux-store/src/UI/PageTree/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export enum actionTypes {
}

const focus = (contextPath: NodeContextPath, _: undefined, selectionMode: SelectionModeTypes = SelectionModeTypes.SINGLE_SELECT) => createAction(actionTypes.FOCUS, {contextPath, selectionMode});
const toggle = (contextPath: NodeContextPath) => createAction(actionTypes.TOGGLE, {contextPath});
const toggle = (contextPath: NodeContextPath, collapseChildren: boolean, childrenContextPaths: NodeContextPath[], childrenCollapsedByDefault: boolean) => createAction(actionTypes.TOGGLE, {contextPath, collapseChildren, childrenContextPaths, childrenCollapsedByDefault});
const invalidate = (contextPath: NodeContextPath) => createAction(actionTypes.INVALIDATE, {contextPath});
const requestChildren = (contextPath: NodeContextPath, {unCollapse = true, activate = false} = {}) => createAction(actionTypes.REQUEST_CHILDREN, {contextPath, opts: {unCollapse, activate}});
const setAsLoading = (contextPath: NodeContextPath) => createAction(actionTypes.SET_AS_LOADING, {contextPath});
Expand Down Expand Up @@ -96,8 +96,16 @@ export const reducer = (state: State = defaultState, action: InitAction | Action
break;
}
case actionTypes.TOGGLE: {
const contextPath = action.payload.contextPath;
if (draft.toggled.includes(contextPath)) {
const {contextPath, collapseChildren, childrenContextPaths, childrenCollapsedByDefault} = action.payload;
if (collapseChildren) {
childrenContextPaths.forEach(child => {
if (!childrenCollapsedByDefault && !draft.toggled.includes(child)) {
draft.toggled.push(child);
} else if (childrenCollapsedByDefault && draft.toggled.includes(child)) {
draft.toggled = draft.toggled.filter(i => i !== child);
}
});
} else if (draft.toggled.includes(contextPath)) {
draft.toggled = draft.toggled.filter(i => i !== contextPath);
} else {
draft.toggled.push(contextPath);
Expand Down
20 changes: 17 additions & 3 deletions packages/neos-ui/src/Containers/LeftSideBar/NodeTree/Node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,23 @@ export default class Node extends PureComponent {
);
}

handleNodeToggle = () => {
const {node, onNodeToggle} = this.props;
onNodeToggle(node.contextPath);
handleNodeToggle = e => {
const {node, onNodeToggle, childNodes, isContentTreeNode, loadingDepth, rootNode} = this.props;
const children = [...childNodes];
const childrenLoaded = children[0] !== undefined;
const childrenContextPaths = [];
let childrenCollapsedByDefault = false;

if (childrenLoaded) {
childrenCollapsedByDefault = loadingDepth === 0 ? false : (node.depth + 1) - rootNode.depth >= loadingDepth;
const childrenWithChildren = children.filter(child => child.children.length > (isContentTreeNode ? 0 : 1));

childrenWithChildren.forEach(child => {
childrenContextPaths.push(child.contextPath);
});
}

onNodeToggle(node.contextPath, e.shiftKey, childrenContextPaths, childrenCollapsedByDefault);
}

handleNodeClick = e => {
Expand Down
5 changes: 2 additions & 3 deletions packages/neos-ui/src/Containers/LeftSideBar/NodeTree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ export default class NodeTree extends PureComponent {
currentlyDraggedNodes: []
};

handleToggle = contextPath => {
handleToggle = (contextPath, collapseChildren, childrenContextPaths, childrenCollapsedByDefault) => {
const {toggle} = this.props;

toggle(contextPath);
toggle(contextPath, collapseChildren, childrenContextPaths, childrenCollapsedByDefault);
}

handleFocus = (contextPath, metaKeyPressed, altKeyPressed, shiftKeyPressed) => {
Expand Down
22 changes: 20 additions & 2 deletions packages/react-ui-components/src/Tree/node.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
margin: 0;
position: relative;
line-height: 20px;

&:hover {
background: var(--colors-PrimaryBlueHover)25;
}
}
.header__chevron {
composes: reset from './../reset.css';
Expand All @@ -18,8 +22,8 @@

cursor: pointer;

&:hover {
color: var(--colors-PrimaryBlue);
&:hover > svg {
color: var(--colors-PrimaryBlueHover);
}
}
.header__chevron--isCollapsed > svg {
Expand All @@ -43,6 +47,11 @@
display: inline-block;
position: absolute;
text-align: center;

.header:hover & > svg,
.header__data--isActive & > svg {
color: var(--colors-PrimaryBlueHover);
}
}

.header__data {
Expand Down Expand Up @@ -74,6 +83,9 @@

.header__data--isFocused {
background: var(--colors-ContrastNeutral);
&:hover {
background: var(--colors-PrimaryBlue)10;
}

&.header__data--isHiddenInIndex,
&.header__data--isHidden {
Expand All @@ -100,9 +112,14 @@
composes: reset from './../reset.css';
margin-left: 2em;

.header:hover &,
.header__data--isActive & {
color: var(--colors-PrimaryBlue);
}

&:hover {
color: var(--colors-PrimaryBlueHover);
}
}

.contents {
Expand All @@ -119,6 +136,7 @@

[data-is-drag-happening] & {
visibility: visible;
height: 5px;
Devclaim marked this conversation as resolved.
Show resolved Hide resolved
}
}
.dropTarget--before {
Expand Down
Loading