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

p-menu in popup mode does not close on scroll in some cases. #17782

Open
4 tasks
demike opened this issue Feb 27, 2025 · 0 comments
Open
4 tasks

p-menu in popup mode does not close on scroll in some cases. #17782

demike opened this issue Feb 27, 2025 · 0 comments
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@demike
Copy link

demike commented Feb 27, 2025

Describe the bug

Szenario:
you have 2 scrollable lists with items inside.
there is one menu with [popup]="true"
clicking on an item will trigger menu.show() and it will show some menu entries.

Steps that lead to the faulty behaviour:

  • click on an item of the first scrollable list
  • menu appears
  • scroll on the first list
  • menu disappears
  • click on an item of the second scrollable list
  • menu appears
  • scroll on the second list
  • !!!!!!!!!!! menu does not disappear !!!!!!!!!!
  • scroll on the first list
  • ????? menu disapperas ?????

The reason is that the scrollHandler still has the reference to the list item of the first list.
This is bad for two reasons:

It holds a reference to a potentially already deleted element (the first target)
menu will never disappear on scrolling of the second list anymore because bindScrollListener wants to bind to the scroll parents of the first element (which is on the first list)
The solution is to remove the scrollHandler member of Menu on unbindScrollListener
--> no more potential leaking of deleted elements
--> works now with differenet targets from different scrollareas passed to show();

Pull Request Link

#17640

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://stackblitz.com/edit/github-wjmgbgjh?file=src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.component.css,src%2Fapp%2Fapp.component.ts

Environment

Windows

Angular version

Angular 18

PrimeNG version

v18 (LTS Only)

Node version

No response

Browser(s)

No response

Steps to reproduce the behavior

  • click on an item of the first scrollable list
  • menu appears
  • scroll on the first list
  • menu disappears
  • click on an item of the second scrollable list
  • menu appears
  • scroll on the second list
  • !!!!!!!!!!! menu does not disappear !!!!!!!!!!
  • scroll on the first list
  • ????? menu disapperas ?????

Expected behavior

Scroll should always hide the menu in popup mode

@demike demike added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

1 participant