-
Notifications
You must be signed in to change notification settings - Fork 6.7k
popover-template directive - addresses issue #220 #1593
Conversation
(Updated comment) The destruction of the tooltip after it's hidden was made for performance reasons (#1455). When the tooltip is not visible, it should no longer attempt to update its contents. If users hover many tooltips each with many directives, the application may slow down due to it trying update DOM that's not visible. This is similar to the difference between ng-if vs ng-show. Perhaps an option needs to be created for this as well. Another possibility to consider is to only keep the one latest tooltip DOM. All other previously hovered tooltips are not kept. This way, hiding/showing the same tooltip will be fast. |
@chrisirhc ... as I've just wrote here: "Are you guys sure that you want to enforce total removal (full destruction of DOM and binded events/data) upon each hide/show of a tooltip/popover? In my use case, there is a popover with Date Picker and other components... this approach is performance killer, as it takes quite some time for it to render. Why not detach? The tooltip/popover is still fully destroyed when the triggering element scope is destroyed. (This is also my case: when the ng-view changes, the tooltip is effectively removed... that's why the scope $destroy listener is there, isn't it?)" Well... I may be wrong, but, at least, I am well aware of the leak issue... relating with the popover issue, Josh first mentioned it here... I myself referred to it later here, here, here... And, in fact, I had to deal with the leaking problem... if you look at my comment explaining the usage of detach, you will see that I linked to the pull request resolving the original eye-opener-issue from Joe Grund. According to my understanding, it is at this comment that Joe explains the leaking problem and also its solution. So, I am sharing all this history above only to make the point that I am not ignoring the leak issue. It is quite the opposite: I believe I am aware of it in depth. At my early first approach writing the So, either I am missing some point to understand what justifies the enforcement of a removal inside "createTooltip" (a step back to the "remove everywhere" style), or, as it seems to me, this enforcement is fruit of a misunderstanding of the issue - thus trying to apply a wrong solution to it. I've already accepted that I may be wrong, and I would really enjoy to be teached and learn any new knowledge I may be missing here. If BTW I am not wrong, then it seems to be just like I've said: the "removal enforcement" in the "createTooltip" does not address the leak issue; the enforcement in the scope destruction does. As the fastest "workaround" for my popover-template upgrade to 0.10.0, I changed the "removeTooltip" for "return" in the "createTooltip" context, and re-enabled the detachment possibility. The "return" simply promotes the usage of the already rendered tooltip. Maybe it is the case of letting the developer decide if it should "detach" or "remove" on close. If there is a "slow to update" thing hidden, better have it removed. But if there is a "slow to render" thing, better have it detached. My use case is this: there is a delay when the popover is opened... but due to the detachment there isn't anymore when it is opened the following times... with removal/re-rendering, there is a delay each and every time the popover is opened. It is a popover which contains not only a date picker but also other inputs. This is why I don't see the current approach as optimal. And I fail to see the other leak potentials since we already have it addressed... see #486 (comment) Thanks for the attention, and forgive me if I'm missing some obvious or not-so-obvious points. Sincerely. |
Sorry, I think you wrote the comment before seeing my update to the above comment. Github doesn't seem to handle edits well. |
Indeed, @chrisirhc, I wrote the previous comment before seeing your updated comment. Well, it seems we had similar ideas. This is nice! Ok. I also understand the above discussion itself, about "detach possibility versus removal enforcement" is in fact totally independent of the current PR. Regarding the PR, I don't expect it to be merged as it is. But people (starting with myself) are using this proposed directive, so I just moved it forward... ok? If someone else could take this effort another step further, and make the "compile scope" available for the directive in a more elegant and less hackish way, it would be great. As for the detach/remove thing, I think we already agreed that there are use cases for both... "how to best implement a solution?" is the new question. At the moment, I do not have availability to focus and dive deeper on these. I can only thank the whole team and community efforts. So... thanks! |
Anyone willing to move this forward, please refer to #1391 (comment) and #1391 (comment). Thank you. |
@jbruni Thank you for your contribution and helping everyone else get this feature. |
@jbruni I added this to my development environment and I have two issues:
Did you also try to fiddle with some transclude stuff? In general I'd think this would be a nice approach but AFAIK would require adding each popover as an EDIT:
|
My latest findings and aches:
|
Guys - back to #1391 (for version 0.9) and #1046 (for version 0.7) it worked fine. In fact, I do use the version 0.7 one (PR 1046) in the project I've delivered to a client. The following update (PR 1391) for version 0.9 was done due to userland request. But this was an easy one to do. The latest update (PR 1593) for version 0.10 - this current PR - was done in a hurry, only due to userland request, and I have NOT in fact used it - I only tested when using a Plunkr to quickly make things work . I am not using it anywhere. My delivered project is fine with version 0.7. While the previous update (0.7 to 0.9) was smooth, the latest (0.9 to 0.10) was the opposite: nothing seemed to work as before. I managed to make it "work" in the Plunkr and went no further. A complete tooltip refactoring is on the way. I am already involved with another projects. I do not have either motivation nor time. In short: I have made my contribution on this, but I do not have availability to continue. I thank you for all support and comprehension! |
Regarding the positioning initially being off, I was able to work around this by wrapping the call to positionTooltip in tooltip.js in a $timeout and calling $templateCache.put('template url', $http.get('template url')) .. not an attempt at an elegant solution, but it seems to be working alright so far for a 2 minute fix. https://github.com/nnpp/bootstrap/blob/master/src/tooltip/tooltip.js#L231 |
For those looking around for this, I've put up a work-in-progress pull request with this feature: #1848 . |
This PR became obsolete, so I'm closing it. |
Addresses feature request "support template url for partial" #220
Improved over @joshdmiller PR #369
Updated from @jbruni PR #1391 for version 0.10.0
Resolves properly the ng-model binding issue seen at http://plnkr.co/edit/cbqOnktHhxSjeLIBE1w7?p=preview