Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Add ability to expand or collapse all the children of selected node #621

Merged
merged 6 commits into from
May 2, 2017

Conversation

shriah
Copy link
Contributor

@shriah shriah commented Apr 23, 2017

Adds #591

Took inspiration from _revealDeep. Not sure how efficient it is when the total nodes are large. Added shortcuts in keyboardNav but not sure if it is the right way to do it. This should work in all the shells.

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact cla@fb.com if you have any questions.

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@@ -26,6 +26,9 @@ var keyCodes = {
'38': 'up',
'39': 'right',
'40': 'down',

'69': 'expand',
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change this to match Chrome shortcuts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will have to add the shortcut to manifest.json of shells/chrome. Right now there is no support for shortcut in any of the plugins. Will spend some time to try to figure out how to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added support for using chrome shortcuts by adding it in the manifest file but the shortcut stopped working in the chrome elements panel. Not sure if this is desired.

I also tried this feature in a recently large react app and the expand all on the root node has a small lag and the close all works well. This lag is there even in the elements panel of chrome so this should be acceptable.

@@ -340,6 +340,14 @@ class Store extends EventEmitter {
this.emit(id);
}

toggle(value: boolean) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we give this a more descriptive name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will toggleAllChildrenNode be more descriptive ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea. ("Nodes" if plural.)

@shriah
Copy link
Contributor Author

shriah commented Apr 30, 2017

Updated the PR with support for chrome shortcuts.

@@ -43,6 +43,17 @@ module.exports = function keyboardNav(store: Store, win: Object): (e: DOMEvent)
return;
}
e.preventDefault();
if ((e.altKey && direction === 'right') || (e.ctrlKey && e.altKey && direction === 'right')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the second condition extraneous? It seems to me that the left is always true when the right is true.
Same below.

Copy link
Contributor Author

@shriah shriah May 2, 2017

Choose a reason for hiding this comment

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

I added this to disallow Ctrl + Right Arrow. The only supported shortcuts are Alt(Option) + Right Arrow or Ctrl + Alt + Right Arrow

Copy link
Contributor

Choose a reason for hiding this comment

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

if (e.altKey && direction === 'right') is enough to match both Alt+Right and Ctrl+Alt+Right, isn't it? And it wouldn't match Ctrl+Right.

if (children && children.forEach) {
children.forEach(cid => this._toggleDeepChildren(cid, value));
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: unnecessary newline.

@gaearon gaearon merged commit 46e0446 into facebook:master May 2, 2017
@gaearon
Copy link
Contributor

gaearon commented May 2, 2017

This looks good, thanks!

@aspiers
Copy link

aspiers commented May 2, 2017

Cool, thanks a lot! What is the shortcut on Linux?

@gaearon
Copy link
Contributor

gaearon commented May 2, 2017

Alt+Right and Alt+Left should work.

@gaearon
Copy link
Contributor

gaearon commented May 2, 2017

(But the change is not released yet.)

@zhanwenchen
Copy link

Is this released yet? It's been 4 months

@bvaughn
Copy link
Contributor

bvaughn commented Aug 31, 2017

Yes 😄 Probably faster to just try it out than post 😁

@zhanwenchen
Copy link

Ah it's Alt+Left_Arrow and Alt+Right_Arrow

@RobBednark RobBednark mentioned this pull request Sep 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants