should not select node on right click if contextMenu is set [p-tree]

UI Components for Angular
Post Reply
max payne
Posts: 3
Joined: 28 Aug 2020, 10:11

28 Aug 2020, 10:36

Hello every one,

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});
            }
        }
    }
You can see a specific behavior when contextMenu is set.
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]);
        }

max payne
Posts: 3
Joined: 28 Aug 2020, 10:11

12 Oct 2020, 15:30

up

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

12 Oct 2020, 21:35

I expect it to behave like Table, so just focuses on the row, no selection by default;

https://primefaces.org/primeng/showcase ... ontextmenu

Could you please create a ticket at issue tracker and we'll take care of it?


andyhilton27
Posts: 1
Joined: 14 Nov 2020, 08:38

15 Nov 2020, 14:38

selectedNode is not invoked when right clicking the node in the example below. ... Tree node not selected when right clicking p:tree with selection and context menu #1133 ... .com/questions/35270792/selected-tree-node-not-set-when-context-menu-action-is-invoked ... What event should be used where?

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 18 guests