Thank you for reporting this bug. We will make it our priority to review this report.
-
TreeList throws exception with dynamic setRoot
Test Case: https://fiddle.sencha.com/#view/editor&fiddle/2lse
Run the test case, see there's an exception thrown in the console in onNodeAppend.
-
Potential fix:
Code:
Ext.define(null, {
override: 'Ext.data.TreeStore',
updateRoot(newRoot, oldRoot) {
this.fireEvent('beforerootchange', newRoot, newRoot, oldRoot);
const initial = this.isConfiguring;
// The rest of the fn
}
});
Ext.define(null, {
override: 'Ext.list.Tree',
updateStore: function(store, oldStore) {
let root;
if (oldStore) {
// Store could be already destroyed upstream
if (!oldStore.destroyed) {
if (oldStore.getAutoDestroy()) {
oldStore.destroy();
} else {
this.storeListeners.destroy();
}
}
this.removeRoot();
this.storeListeners = null;
}
if (store) {
this.storeListeners = store.on({
destroyable: true,
scope: this,
filterchange: 'onFilterChange',
nodeappend: 'onNodeAppend',
nodecollapse: 'onNodeCollapse',
nodeexpand: 'onNodeExpand',
nodeinsert: 'onNodeInsert',
noderemove: 'onNodeRemove',
beforerootchange: 'onBeforeRootChange',
rootchange: 'onRootChange',
update: 'onNodeUpdate'
});
root = store.getRoot();
if (root) {
this.createRootItem(root);
}
}
if (!this.destroying) {
this.updateLayout();
}
},
privates: {
onBeforeRootChange() {
this.rootChanging = true;
},
onRootChange(root) {
this.rootChanging = false;
this.callParent([root]);
},
onNodeAppend(parentNode, node) {
if (this.rootChanging) {
return;
}
this.callParent([parentNode, node]);
}
}
});
IMO the initial flag is incorrectly set only if we didn't have a root before. The intent is to not do those things during construction, however the root can come at a later time.