vakata / jstree

jquery tree plugin
http://jstree.com
MIT License
5.15k stars 1.38k forks source link

Selected node not fire event when select again #2726

Closed Sega100500 closed 1 year ago

Sega100500 commented 1 year ago

Selected node not fire event when select again

After upgrade jsTree from 3.3.12 to 3.3.15 selected node not fire event on select again

When first time select node - it fire event, when try again to select (by mouse click) selected node - no events fire.

Sega100500 commented 1 year ago

I find difference between 3.3.12 and 3.3.13 (and later) in jstree.js:

3.3.12

if(!this.settings.core.multiple && (e.metaKey || e.ctrlKey || e.shiftKey) && this.is_selected(obj)) {
   this.deselect_node(obj, false, e);
}
else {
   this.deselect_all(true);
   this.select_node(obj, false, false, e);
   this._data.core.last_clicked = this.get_node(obj);
}

3.3.13

if(!this.settings.core.multiple && (e.metaKey || e.ctrlKey || e.shiftKey) && this.is_selected(obj)) {
   this.deselect_node(obj, false, e);
}
else {
   if (!this.is_selected(obj) || this._data.core.selected.length !== 1) {
      this.deselect_all(true);
      this.select_node(obj, false, false, e);
   }
   this._data.core.last_clicked = this.get_node(obj);
}

Everything seems to be correct, but even the selected node should receive at least some event that it is selected again. For example, in my case it is useful for reloading content via ajax.

You can not select the node again, but at least send (fire) some kind of event.

Otherwise, the selected node is completely excluded from receiving events about its selection again.

Please fix this.

vakata commented 1 year ago

Added the allow_reselect option to core config - set it to true, to revert the problematic change.