Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

How to hide the tooltip when it's empty? #129

Closed
moroshko opened this issue Feb 10, 2013 · 3 comments
Closed

How to hide the tooltip when it's empty? #129

moroshko opened this issue Feb 10, 2013 · 3 comments

Comments

@moroshko
Copy link

When using <div tooltip="{{ myTooltip }}">...</div>, and myTooltip is an empty string (or null or undefined), it seems reasonable not to show the tooltip. At the moment, an empty tooltip is shown, which looks a bit weird. I would suggest to hide the tooltip in this case.

What would be the best way to achieve this with the current functionality?

@pkozlowski-opensource
Copy link
Member

OK, I see, thnx for pointing this out. I agree that it doesn't make much sense to show empty tooltips. Don't know how the original tooltip behaves in this respect but anyway, we yes, we shouldn't be showing tooltips when they content is empty.

As a work-around you might try changing the default template (https://github.com/angular-ui/bootstrap/blob/master/template/tooltip/tooltip-popup.html) and add this condition for the in class: in: isOpen() && tooltipTitle. It should do the trick but it would mean that we still do DOM manipulations for nothing so ultimatelly it should be fixed in code. I guess it will be a relatively small change so a pull request would be awesome!

@joshdmiller
Copy link
Contributor

It should be pretty straightforward; just check for scope.tt_tooltip at the top of show and return; when there's nothing to show. I should be able to get to this in the next few days, but a pull request would rock. :-)

I guess something similar should be done for the popover too...

@pkozlowski-opensource
Copy link
Member

@moroshko pushed a fix + test. It is not released yet but you can get a SNAPSHOT version from http://ci.angularjs.org/job/angularui-bootstrap/ws/dist/

@joshdmiller not sure how this should work for popover. Anyway, we've got a test now so even if we harmonize things we are safe, we shouldn't miss this use case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants