Make alt click expand/collapse all the nodes#4309
Conversation
|
Nice @Fischer-L! |
|
I didn't know this feature existed in other places like finder and chrome! |
Yes this alt click feature exists on Chrome's devtool, finder and Sublime, which is handy. |
| } | ||
|
|
||
| setExpanded = (item: Item, isExpanded: boolean) => { | ||
| setExpanded = (item: Item, isExpanded: boolean, isRecursive: boolean) => { |
There was a problem hiding this comment.
i'm thinking something like shouldIncludeChildren feels better and clearer then isRecursive
| expanded.delete(itemPath); | ||
| } | ||
| if (isRecursive) { | ||
| let children = null; |
| let children = null; | ||
| let parents = [item]; | ||
| while (parents.length) { | ||
| children = []; |
There was a problem hiding this comment.
... and make this const children = [];
| expanded.add(itemPath); | ||
| } else { | ||
| expanded.delete(itemPath); | ||
| } |
There was a problem hiding this comment.
We could pull this into a local function like this here
const toggleItem = item => {
const path = this.props.getPath(item);
if (isExpanded) {
expanded.add(path);
} else {
expanded.delete(path);
}
};There was a problem hiding this comment.
Then do toggleItem(item); here
| } | ||
| children.push(child); | ||
| } | ||
| } |
There was a problem hiding this comment.
This for loop can become
for (const parent of parents) {
if (parent.contents && parent.contents.length) {
for (const child of parent.contents) {
toggleItem(child);
children.push(child);
}
}
}There was a problem hiding this comment.
As you should not need the continue ...
There was a problem hiding this comment.
And may not need nodeHasChildren since you only use parent.contents anyway, you can just check that
| @@ -1,5 +1,6 @@ | |||
| // @flow | |||
| import React, { createFactory, Component } from "react"; | |||
| import { nodeHasChildren } from "../../utils/sources-tree"; | |||
|
@Fischer-L Great Stuff here! left some comments.. |
807c0e1 to
a6e6e37
Compare
|
@Fischer-L i fixed up the few comments so we could landing this ... Thanks for the amazing Work!!!! |
Associated Issue: #4061
Summary of Changes
Expand/Collapse all nodes in the source tree when doing alt click on the tree item(folder)
Screenshots