Skip to content

Bug: Sparse dir listing on tree collapse #104

@dereks

Description

@dereks

If using config.listFiles set to false, which enables showing just sub-directories in the tree, there is a weird UX error.

When you click on a dir in the tree, to expand it and show its contents, everything works as expected. All files are shown in the detail pane, but only dirs are shown in the tree.

But if you click the dir in the tree again, to collapse the (expanded) node, there is a bug where the detail pane suddenly shows only the sub-dirs. The files are suddenly hidden.

The error is in this function:

this.openNode = function(node) {
	if(node.rdo.type === 'file') {
		getDetailView(node.rdo);
	}
	if(node.rdo.type === 'folder' && node.isLoaded()) {
		var childrenObjects = [];
		if(node.children().length) {
			$.each(node.children(), function(index, cNode) {
				childrenObjects.push(cNode.rdo);
			});
		}
		model.currentPath(node.rdo.id);
        model.breadcrumbsModel.splitCurrent();
		model.itemsModel.setList(childrenObjects);
	}
};

When openNode() is called the second time (after the node has been expanded), node.isLoaded() is true, and it falls to re-using the previously loaded children with model.itemsModel.setList(childrenObjects); But thanks to config.listFiles only the sub-dirs are present in childrenObjects. This causes the detail pane to suddenly show only the sub-dirs, when all the user wanted to do was collapse the tree element.

My first attempt at a fix fell back to doing an AJAX load of dir contents everytime, regardless of whether it was previously expanded or not. That fixes the symptom described above.

But after playing around with the tree for a while, I feel strongly that it's much more intuitive if collapsing the node doesn't change the detail pane at all (i.e., collapsing a dir does not changeDir into that dir). It should just be a passive "collapse this dir node -- I'm done with it", rather than a "collapse this dir node, but also switch to it in the detail pane".

So I will submit a PR with this fix shortly. It will fix the bug but also change the behavior so that collapsing a dir node does not show that dir's contents -- the user is now able to collapse tree nodes but stay with their current detail view.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions