Open smahn9123 opened 1 year ago
I found the answer:
jstree defines the prototype of its node in the init stage, and here the 'jstree-icon jstree-ocl' class is used. This does not have any icon related class.
$.jstree.core.prototype = {
...
_create_prototype_node : function () {
...
_temp1.className = 'jstree-icon jstree-ocl';
...
init : function (el, options) {
this._data.core.node = this._create_prototype_node();
...
When the name of node is changed, rename_node() -> set_text() -> redraw_node() is called inside jstree. redraw_node() removes the existing node and creates a new node from the prototype to replace the existing node.
redraw_node : function (node, deep, is_callback, force_render) {
...
node.remove();
//node = d.createElement('LI');
//node = node[0];
}
node = this._data.core.node.cloneNode(true);
...
When rename_node() is called, any pre-set icon-related class is gone as the node element is replaced.
Thus, the user(ipytree) has to set it - Which exactly is what NodeView's setOpenCloseIcon() does.
Below is a node icon element with open icon related class added:
<i class="jstree-icon jstree-ocl fa fa-plus ipytree-style-default" role="presentation"></i>
So it seems to me that this problem is a bug. I'll work on a PR to address this.
Opened #84 .
In a nested Tree, when changing name of node like below, +/- icons disappear.
I do know this can be resolved by calling NodeView's setOpenCloseIcon(), but I would really like to know why this occurs in the first place.