Improve event bindings on OverlayPanel and ContextMenu to avoid unnecessary change detection
I'm submitting a ... (check one with "x")
[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35
Plunkr Case (Bug Reports) Please fork the plunkr below and create a case demonstrating your bug report. Issues without a plunkr have much less possibility to be reviewed.
http://plnkr.co/edit/pIKtgnZXEYNQA4cJed7k?p=preview
Current behavior Every overlayPanel and contextMenu seems to trigger the change detection on every click in the page, even if they are not visible.
Expected behavior The change detection should be triggered just one time for all (and maybe just if at least one is visible)
Minimal reproduction of the problem with instructions see the plunker, it just has 3 overlaypanel and 2 contextMenu and a change detection counter. Click wherever in the page and you'll see the counter going up by five.
What is the motivation / use case for changing the behavior? when combining multiple components that use an overlayPanel or a contextMenu, every click cause multiple change detections, causing lag when there are about 10/15 of them.
-
Angular version: 4.3.4
-
PrimeNG version: 4.1.2
-
Browser: Chrome 60
-
Language: TypeScript 2.4.2
the same issue involve menu when setting popup property to true
https://github.com/primefaces/primeng/commit/5c866710a803022c798245a93e0ed76a72dfb51c