Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Added 'Collapse File Tree' feature #7026

Merged
merged 3 commits into from
Mar 24, 2014
Merged

Added 'Collapse File Tree' feature #7026

merged 3 commits into from
Mar 24, 2014

Conversation

zaggino
Copy link
Contributor

@zaggino zaggino commented Feb 27, 2014

When working with a file tree, I miss the ability to collapse whole section recursively - so when I open the top directory again later, not everything under it will also be expanded. This is a feature for it.

Sample:
I want to collapse everything under "test" folder and when I open "test" folder again, I don't want to see "node", "node-modules", "fs-extra" and "lib" expanded too.
image

@@ -245,6 +245,7 @@ define({
"CMD_INSTALL_EXTENSION" : "Install Extension\u2026",
"CMD_EXTENSION_MANAGER" : "Extension Manager\u2026",
"CMD_FILE_REFRESH" : "Refresh File Tree",
"CMD_FILE_TREE_COLLAPSE" : "Collapse File Tree",
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should name it something like "Collapse Subtree" to make it clear it's not collapsing all nodes in the tree view.

@zaggino
Copy link
Contributor Author

zaggino commented Feb 27, 2014

Renamed @peterflynn

@TomMalbran
Copy link
Contributor

Should we make this a "ctrl/cmd" + click command, similar to how is done in the Find in Files panel instead of adding a new command and menu item?

@zaggino
Copy link
Contributor Author

zaggino commented Feb 28, 2014

That's also not a bad idea. Though I don't think many uses would be able to find that feature if they were looking for it.

@TomMalbran
Copy link
Contributor

We can add a title tooltip as is done in the Find in Files panel.

@peterflynn
Copy link
Member

@TomMalbran I thought about suggesting that too -- especially since I dislike adding extra clutter to the context menu. But I think this is actually a different gesture: ctrl/cmd-click usually means collapse all, whereas this only collapses the specific subtree that you clicked on. It might be weird to overload the gesture for these two different things (though if there's precedent in for it in other editors, it'd be fine with me!).

@pthiess
Copy link
Contributor

pthiess commented Feb 28, 2014

@larz0 Hi Larz may you please take a look at this and provide some guidance as how to proceed.

@larz0
Copy link
Member

larz0 commented Feb 28, 2014

We could add a new shortcut for the triangle, cmd/ctrl+alt click to expand/collapse subtrees (cmd+click for siblings).

@larz0
Copy link
Member

larz0 commented Mar 1, 2014

Initial UX review done.

@zaggino
Copy link
Contributor Author

zaggino commented Mar 1, 2014

so -

  1. remove from menu
  2. add as a ctrl+alt(cmd)+click function
  3. alt(cmd)+click new function for siblings of current
    ok? i'll do it after the weekend

@marcelgerber
Copy link
Contributor

@zaggino Your number 3 is already filed as #6721. Just to let you know.

@zaggino
Copy link
Contributor Author

zaggino commented Mar 2, 2014

Done, only thing missing is handling of the Mac's command key, I'm not sure if jQuery handles alt and cmd as the same key or not.

@TomMalbran
Copy link
Contributor

@zaggino It doesn't. You can just use if (e.metaKey || e.ctrlKey) { as is done in https://github.com/adobe/brackets/blob/master/src/search/FindInFiles.js#L442

@zaggino
Copy link
Contributor Author

zaggino commented Mar 3, 2014

Thanks @TomMalbran, done.

@TomMalbran
Copy link
Contributor

The shortcuts seem wrong.

  • 2 should be ctrl/cmd+alt+click
  • 3 should be ctrl/cmd+click

@zaggino
Copy link
Contributor Author

zaggino commented Mar 3, 2014

I'm confused, I though Mac got Ctrl key but no Alt key...

@zaggino
Copy link
Contributor Author

zaggino commented Mar 3, 2014

Oh there's a option key that servers as alt... my god.

@zaggino
Copy link
Contributor Author

zaggino commented Mar 3, 2014

Ok - this should be fine now :)

@marcelgerber
Copy link
Contributor

I don't think the "toggle siblings" feature should be done like this.
Imo:

  • If the clicked node is open, close all
  • If the clicked node is closed, open all
    This is the same way we do it in Find in Files.
                        else {
                            // toggle siblings
                            var methodName = $node.is(".jstree-open") ? "close_node" : "open_node";
                            $node.parent().children("li").each(function () {
                                _projectTree.jstree(methodName, $(this));
                            });
                            return;
                        }

@zaggino
Copy link
Contributor Author

zaggino commented Mar 3, 2014

Thanks @SAplayer, that was actually an issue I didn't realize. Fixed now.

@larz0
Copy link
Member

larz0 commented Mar 3, 2014

Cmd+alt(opt) click doesn't work for me for some reason. Can't wait for this PR, it's one of those small things that'll save so much time. 👍

@zaggino
Copy link
Contributor Author

zaggino commented Mar 3, 2014

Definitely works on my win, but I don't have cmd key to test it :-/

// note: expanding using open_all is a bad idea due to poor performance
if ($node.is(".jstree-open")) {
_projectTree.jstree("close_all", $node);
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should return true 'cause we handled the event. Same below.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is not returning to anything, it is just used so that it doesn't drop into the original behavior case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@zaggino the if (event.altKey)... branch doesn't seem to do anything differently than without using the ctrl key. I'm not sure what it's supposed to do but, after using it, it felt like ctrl+click doesn't work anymore.

/cc: @larz0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the intended behaviour:

ctrl+click willl expand - collapse all siblings of the one that has been clicked

ctrl+alt+click will collapse just the one tree clicked, and all of its children (it doesn't work reverse for expand because it's slow)

point is if I have a tree open like

a
    -b
         -b1
         -b2
         -b3
    -c
         -c1
              -cc1
    -d

clicking ctrl+alt on a will cause all children to collapse, so if I open a again, I'll see only b,c,d and not b1,b2,b3,c1,cc1

Copy link
Contributor

Choose a reason for hiding this comment

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

ahhh... I think I understand the problem now. You need to handle clicking on the label too not just the disclosure triangle. Alt+clicking on the label is handled by jstree and feels somewhat unpredictable.

@zaggino
Copy link
Contributor Author

zaggino commented Mar 7, 2014

I've just tested this on my Mac virtual machine and it works for me.
Windows key acts like command key there and clicking win+alt works just fine.
I'm not able to test on a real Mac though...

@larz0
Copy link
Member

larz0 commented Mar 8, 2014

UX review done. I'm going to pass this on and hopefully someone will have a Mac to test this on.

@larz0 larz0 removed their assignment Mar 8, 2014
@njx
Copy link
Contributor

njx commented Mar 14, 2014

FWIW, on Mac, it looks like Alt does this functionality in Finder.

@njx
Copy link
Contributor

njx commented Mar 14, 2014

To @JeffryBooher

@zaggino
Copy link
Contributor Author

zaggino commented Mar 20, 2014

@JeffryBooher can you review again? Clicking on the labels is handled now.

if (event.altKey) {
// collapse subtree
// note: expanding using open_all is a bad idea due to poor performance
if ($node.is(".jstree-open")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the other part of my confusion was that cmd+alt doesn't open all. If there is a performance hit with open all then let's just open the node that was clicked on as if alt wasn't pressed.

@zaggino
Copy link
Contributor Author

zaggino commented Mar 24, 2014

@JeffryBooher fixed the latest comment

@JeffryBooher
Copy link
Contributor

Looks good. Merging.

JeffryBooher added a commit that referenced this pull request Mar 24, 2014
Added 'Collapse File Tree' feature
@JeffryBooher JeffryBooher merged commit f9667cb into adobe:master Mar 24, 2014
@zaggino zaggino deleted the collapse-tree branch March 24, 2014 22:08
@bchintx
Copy link
Contributor

bchintx commented Mar 27, 2014

Ok, I think I understand the desired behavior now. I've confirmed the following:

  1. alt + ctrl/cmd + click (on an expanded folder) = recursively close all subfolders
  2. ctrl/cmd + click = opens or closes all sibling folders (but doesn't affect already expanded subfolders)

Was a bit confused initially since (1) above doesn't change anything when expanding a folder.

Tested on both Mac and Windows 7 (VM).

@peterflynn
Copy link
Member

@zaggino @JeffryBooher Fyi, looks like this introduced some JSLint nits in ProjectManager (via 151f3c1). I think I have to touch this file anyway in #7300, so I can fix it in my PR.

@zaggino
Copy link
Contributor Author

zaggino commented Mar 31, 2014

Thanks @peterflynn ... I have to remember to disable JSHint because it overrides JSLint's checks ...

peterflynn added a commit that referenced this pull request Apr 1, 2014
contains the user prefs JSON files in its subtree) - ensure that FileSystem
always knows we've read the JSON file before we try to write to it. We
don't want to enable the 'blind' flag since it will mean we virtually
always overwrite external changes to the prefs file, and we don't want to
start using file watchers to observe external changes on the fly since
we haven't yet deeply tested having multiple watch roots active at once.
- Rename confusing "filename" vars in PreferencesBase
- Fix JSLint errors in ProjectManager from #7026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants