OverlayPanel performance issue
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) http://plnkr.co/edit/LMvtleJc1CFfo4cMyRQQ?p=preview
Current behavior Using a lot of OverlayPanels causes performance issue due to many active document click event listeners.
Expected behavior Assumed that document's click listener is only needed for detection if click happened outside overlay, it should only be attached when overlay is shown (and detached when overlay hides).
Minimal reproduction of the problem with instructions In plunkr above, check documents click event listeners in dev tools. There are 10(!) of them.
What is the motivation / use case for changing the behavior? Avoid performance issues.
Please tell us about your environment: Windows 10, Angular 4.2.4, Primeng 4.1.0 RC2 (but 4.1.3 also affected), all Browsers
every listener seem to cause a change detection run, so 10 overlay -> 10 change detection run per click. The same apply to context-menu and menu components (when using popup). see #3671
Duplicate of #3671