Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu closes itself immediately when the menu and its button toggle is inside ShadowDom #16298

Closed
hyilai opened this issue Aug 27, 2024 · 1 comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@hyilai
Copy link

hyilai commented Aug 27, 2024

Describe the bug

p-menu cannot be opened when the menu and its button toggle is inside ShadowDom encapsulation. The menu closes itself right away.

This seems to be caused by bindDocumentClickListener. Inside the shadow dom, event.target will be the shadow root even if the button itself is clicked, so isOutsideContainer‎ and isOutsideTarget are always true. It might need to check if the event is composed and if the toggle element contains the first element of the event's composed path (event.composed ? toggleElement.contains(event.composedPath()[0]) : toggleElement.contains(event.target)).

Environment

Angular app with PrimeNG

Reproducer

https://stackblitz.com/edit/github-fhq1jp?file=src%2Fapp%2Fapp.component.html

Angular version

17.3.7

PrimeNG version

17.18.8

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

21.7.1

Browser(s)

No response

Steps to reproduce the behavior

  • Create a component with a popup p-menu and button to toggle the menu.
  • Wrap that component around with another component that has ShadowDom encapsulation.
  • In primeng-menu.mjs, put a debug point inside the hide() function.
  • Click on the button. The debug point will pause inside hide().
  • The menu is visible when the debug point is paused. After the debug point resumes, the menu will disappear.

Expected behavior

p-menu should stay opened.

@hyilai hyilai added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Aug 27, 2024
kapnak added a commit to kapnak/primeng that referenced this issue Oct 19, 2024
@kapnak kapnak mentioned this issue Oct 19, 2024
@mertsincan mertsincan added this to the 17.18.13 milestone Nov 18, 2024
@mertsincan mertsincan added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Nov 18, 2024
@mertsincan mertsincan moved this to Done in PrimeNG Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
Status: Done
Development

No branches or pull requests

3 participants
@mertsincan @hyilai and others