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

Tooltip fails when closing on an element that's removed #3347

Closed
WilcoFiers opened this issue Feb 27, 2015 · 6 comments · Fixed by #4455
Closed

Tooltip fails when closing on an element that's removed #3347

WilcoFiers opened this issue Feb 27, 2015 · 6 comments · Fixed by #4455

Comments

@WilcoFiers
Copy link

I'm using the tooltip on a delete button, which delete a row in a table. The button has a mouse enter/leave effect. When I click the button, which is then deleted with an animation, the following error is logged:
Uncaught TypeError: Cannot read property 'isOpen' of null

The following seems to fix the problem:
function toggleTooltipBind () {
if (!ttScope) return; // Check that the element still exists.
if ( ! ttScope.isOpen ) {
showTooltipBind();
} else {
hideTooltipBind();
}
}

@karianna
Copy link
Contributor

plunkr please

@wesleycho wesleycho added this to the Purgatory milestone Aug 6, 2015
@wesleycho
Copy link
Contributor

Closing this issue as potentially old, and due to lack of reproduction.

Feel free to open a new issue if you are able to reproduce this on Plunker.

@btrauma8
Copy link
Contributor

btrauma8 commented Sep 4, 2015

I can reproduce this with a plunkr!

http://plnkr.co/edit/gXcpxofs6PMJ1M7LaCfy?p=preview

my fix is just "if (!ttScope) return;" as first line of hide() function

@wesleycho wesleycho reopened this Sep 4, 2015
@wesleycho
Copy link
Contributor

That's a reasonable & simple fix - would you like to file a PR with it? If not, I can do so, but you should get the credit :) .

@SyntaxUnknown
Copy link

We're actually hitting this error in several other locations in our application:

        attrs.$observe( prefix+'Title', function ( val ) {
          Here --> ttScope.title = val;
          positionTooltipAsync();
        });

        attrs.$observe( prefix + 'Placement', function () {
         Here -->  if (ttScope.isOpen) {
            $timeout(function () {
              prepPlacement();
              show()();
            }, 0, false);
          }
        });

It seems for our issue, problem that ttScope is set to null here:

        // Make sure tooltip is destroyed and removed.
        scope.$on('$destroy', function onDestroyTooltip() {
          $timeout.cancel( transitionTimeout );
          $timeout.cancel( popupTimeout );
          unregisterTriggers();
          removeTooltip();
          ttScope = null;
        });

but the attrs.$observe() calls are not released. It seems those are still firing after $destroy happens in my tests.

For each attrs.$observe(), it should hold on to the return value and then call it during release, correct?

@wesleycho
Copy link
Contributor

Good call - we need to investigate this further.

@wesleycho wesleycho reopened this Sep 9, 2015
NealHaggard pushed a commit to NealHaggard/bootstrap that referenced this issue Oct 7, 2015
- Do nothing on hide when `$scope` is already removed

Closes angular-ui#4346
Fixes angular-ui#3347
jasonaden pushed a commit to deskfed/bootstrap that referenced this issue Jan 8, 2016
- Do nothing on hide when `$scope` is already removed

Closes angular-ui#4346
Fixes angular-ui#3347
jasonaden pushed a commit to deskfed/bootstrap that referenced this issue Jan 8, 2016
This is a rollup commit intended to address several
issues around the positioning and parsing of
attributes.

- Fixes issue introduced under PR angular-ui#4311 where setting
  height and width in tooltip position function
  messed up arrow placement.
- Fixes issue introduced under PR angular-ui#4363 where setting
  visibility to hidden in tooltip position function
  caused elements in popover to lose focus.
- Fixes issue angular-ui#1780 where tooltip would render if
  content was just whitespace.
- Fixes issue angular-ui#3347 where tooltip isolate scope was
  being accessed after it was set to null.  Observers
  will now be created/destroyed as tooltip opens/closes
  which will also offer a performance improvement.
- Fixes issue angular-ui#3557 by implementing evalAsync to set
  tooltip scope isOpen property.
- Fixes issue angular-ui#4335 where if model isOpen property is
  undefined, tooltip would call show/hide toggle function.
- Closes PR angular-ui#4429 where how the templated content
  was being evaluated could cause an infinite digest loop.

Closes angular-ui#4400
Closes angular-ui#4418
Closes angular-ui#4429
Closes angular-ui#4431
Closes angular-ui#4455

Fixes angular-ui#1780
Fixes angular-ui#3347
Fixes angular-ui#3557
Fixes angular-ui#4321
Fixes angular-ui#4335
jasonaden pushed a commit to deskfed/bootstrap that referenced this issue Jan 8, 2016
- Do nothing on hide when `$scope` is already removed

Closes angular-ui#4346
Fixes angular-ui#3347
jasonaden pushed a commit to deskfed/bootstrap that referenced this issue Jan 8, 2016
This is a rollup commit intended to address several
issues around the positioning and parsing of
attributes.

- Fixes issue introduced under PR angular-ui#4311 where setting
  height and width in tooltip position function
  messed up arrow placement.
- Fixes issue introduced under PR angular-ui#4363 where setting
  visibility to hidden in tooltip position function
  caused elements in popover to lose focus.
- Fixes issue angular-ui#1780 where tooltip would render if
  content was just whitespace.
- Fixes issue angular-ui#3347 where tooltip isolate scope was
  being accessed after it was set to null.  Observers
  will now be created/destroyed as tooltip opens/closes
  which will also offer a performance improvement.
- Fixes issue angular-ui#3557 by implementing evalAsync to set
  tooltip scope isOpen property.
- Fixes issue angular-ui#4335 where if model isOpen property is
  undefined, tooltip would call show/hide toggle function.
- Closes PR angular-ui#4429 where how the templated content
  was being evaluated could cause an infinite digest loop.

Closes angular-ui#4400
Closes angular-ui#4418
Closes angular-ui#4429
Closes angular-ui#4431
Closes angular-ui#4455

Fixes angular-ui#1780
Fixes angular-ui#3347
Fixes angular-ui#3557
Fixes angular-ui#4321
Fixes angular-ui#4335
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants