I'm a new primeNger and I've found a weird behavior with the Tree component when I right click on a node and with the contextMenu set.
Indeed, in that case , the node is selected and propagate the information neither to ancestors and descendants. But moreover, I don't think this behavior make senses.
I expect that even when the contextMenu is on, the right click should not select any node like when the contextMenu is not set.
If you look at the onNodeRightClick method in tree component,
Code: Select all
onNodeRightClick(event: MouseEvent, node: TreeNode) {
if (this.contextMenu) {
let eventTarget = (<Element> event.target);
if (eventTarget.className && eventTarget.className.indexOf('p-tree-toggler') === 0) {
return;
}
else {
let index = this.findIndexInSelection(node);
let selected = (index >= 0);
if (!selected) {
if (this.isSingleSelectionMode())
this.selectionChange.emit(node);
else
this.selectionChange.emit([node]);
}
this.contextMenu.show(event);
this.onNodeContextMenuSelect.emit({originalEvent: event, node: node});
}
}
}
I think the following code should be removed:
Code: Select all
let index = this.findIndexInSelection(node);
let selected = (index >= 0);
if (!selected) {
if (this.isSingleSelectionMode())
this.selectionChange.emit(node);
else
this.selectionChange.emit([node]);
}