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

Retain Expanded/Selected Rendering #5

Merged

Conversation

danhunsaker
Copy link
Contributor

When a tree model is replaced by a new object, even if that object's contents are identical to the previous value, the entire treecontrol is reloaded from scratch, and since each node has its own scope, the tree appears to forget what has been expanded or selected when the "new" nodes are attached with their new scopes. Additionally, if you expand/select an item, then collapse and re-expand any of its parents, the same symptom applies to the children of the re-expanded node, for the same reason.

This PR fixes both scenarios by first detecting whether a "new" tree model is any different from the previous version, and doing nothing if not, then by using a configurable equality function to determine whether a new node is equivalent to an old one, and applying the old one's expanded/selected status to the new. The default equality function, as indicated in the updated README, first discards any child nodes, then returns the result of angular.equals() against the old and new nodes.

Also added tests (and fixed bugs that prevented them from passing on the first attempt) and updated package.json to agree with bower.json on the package version.

Also added tests and updated README.md.
Additionally, updated package.json to agree with bower.json on the package version.

Signed-off-by: Daniel Hunsaker <danhunsaker@gmail.com>
Stupidly neglected to run tests locally on the changes, so nearly everything failed.
The bugs introduced that caused these failures have been resolved.  All tests now pass.

Signed-off-by: Daniel Hunsaker <danhunsaker@gmail.com>
yoavaa added a commit that referenced this pull request Jan 26, 2014
@yoavaa yoavaa merged commit 3310ca8 into wix-incubator:master Jan 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants