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

Create files on collapsed folders (#2085) #2198

Merged
merged 1 commit into from
Dec 5, 2012
Merged

Create files on collapsed folders (#2085) #2198

merged 1 commit into from
Dec 5, 2012

Conversation

jbalsas
Copy link
Contributor

@jbalsas jbalsas commented Nov 23, 2012

This is a possible fix for #2085 by waiting on the open_node.jstree event before trying to create a new node.

It looks like we're hitting a strange race condition in jsquery.jstree.js which appears when the node we want to open hasn't been loaded yet.

In that case, open_node triggers a load_node in line 640.

632  open_node  : function (obj, callback, skip_animation) {
         [...]
638      if(!this._is_loaded(obj)) {
639          obj.children("a").addClass("jstree-loading");
640          this.load_node(obj, function () { t.open_node(obj, callback, skip_animation); }, callback);
641      }

Almost at the same time, a different load_node is triggered from the CRRM create through create_node in line 734

726  create_node    : function (obj, position, js, callback, is_loaded) {
         [...]
733      if(obj !== -1 && !obj.length) { return false; }
734      if(!is_loaded && !this._is_loaded(obj)) { this.load_node(obj, function () { this.create_node(obj, position, js, callback, true); }); return false; }
735
736      this.__rollback();

Not digging much further, if the second load_node gets called because the first one is not completed, then create_node is not called again as expected and nothing gets created. This can be tested by adding a breakpoint in line 733. Doing that, the first load_node always finishes and the function completes ok.

By waiting to the open_node event, we're making sure we always step into create_node once the node is already loaded.

UPDATE Just to confirm, the load_node_json call just returns without doing nothing if the node is already being loaded, which causes the callback to create_node to get dropped without ever being called. Also, this check seems to have been removed in the v1.0 branch (https://github.com/vakata/jstree/blob/v.1.0/src/jstree.json.js)

@ghost ghost assigned gruehle Nov 26, 2012
@gruehle
Copy link
Member

gruehle commented Dec 5, 2012

Works great! Thanks for the fix.

gruehle added a commit that referenced this pull request Dec 5, 2012
Create files on collapsed folders (#2085)
@gruehle gruehle merged commit 5453d95 into adobe:master Dec 5, 2012
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.

None yet

2 participants