Skip to content

Tree - Context menu can't be opened using keyboard #19554

@infe42

Description

@infe42

Describe the bug

The context menu of a tree item can't be opened using the keyboard (context menu key or context menu shortcut), because the (contextmenu) event listener is attached to the wrong element - the <li> is focused, but the event listener is on the <div> inside it.

Pull Request Link

#18254

Reason for not contributing a PR

  • Lack of time
  • Unsure how to implement the fix/feature
  • Difficulty understanding the codebase
  • Other

Other Reason

No response

Reproducer

https://primeng.org/tree#contextmenu

Environment

Angular version

21.x.x

PrimeNG version

v21

Node version

No response

Browser(s)

all

Steps to reproduce the behavior

  1. Go to https://primeng.org/tree#contextmenu
  2. Click a tree item
  3. Press the context menu key or the context menu shortcut (Shift + F10 in Chrome)
    Actual behavior: The browser context menu is opened instead of the tree context menu.

Expected behavior

The tree context menu is opened.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: AccessibilityIssue or pull request is related to WCAG or ARIAType: BugIssue contains a bug related to a specific component. Something about the component is not working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions