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

fix(modal): should not throw an exception when a modal isn't on the stack #1972

Closed
wants to merge 1 commit into from

Conversation

venuatu
Copy link
Contributor

@venuatu venuatu commented Mar 23, 2014

No description provided.

@chrisirhc
Copy link
Contributor

Looks like a good addition.

@bekos
Copy link
Contributor

bekos commented Apr 12, 2014

@venuatu OK, this seems like a logic change, but I would like to know the case that you try to dismiss an already dismissed modal.

@AidasK
Copy link

AidasK commented Apr 17, 2014

When this is going to be released? This is a very ugly issue.
For me this happens in watch statement:

$scope.$watch('files.length', function () {
  if (files.length == 0) {
    $scope.$close();
  }
});

@venuatu
Copy link
Contributor Author

venuatu commented Apr 27, 2014

I had some code which was a crud list with a single modal up at a time and it broke on this issue when I upgraded from 0.6 (iirc) to the latest version
When I looked at what was breaking it looked like the original intent was to allow for this behaviour
The code I had was something like:

var modal;

function closeModal() {
    if (modal)
        modal.close();
    modal = undefined;
};

$scope.updateSomething = function (something) {
    closeModal();
    modal = $modal.open(...)
};

$scope.$on('$destroy', closeModal);

@pkozlowski-opensource
Copy link
Member

@venuatu thnx for this PR. Could you please rebase on top of the current master and squash commits so there is only one commit in the pull request?

$modalStack.openWindows.get(modalInstance) is undefined after the first dismiss and throws:
-   TypeError: Cannot read property 'value' of undefined
@venuatu
Copy link
Contributor Author

venuatu commented May 3, 2014

@pkozlowski-opensource done

@pkozlowski-opensource
Copy link
Member

Merged, thnx @venuatu !

@AidasK
Copy link

AidasK commented May 6, 2014

Uhhh, and this is not in the release 11.0 :/

@byeval
Copy link

byeval commented Sep 19, 2014

thx~

@johannesjo
Copy link

This should be merged asap!

@chaizhenhua
Copy link

hi, can this patch fix this error ? or is this error already fixed ?

"Error: openedWindows.get(...) is undefined
$modalStack.close@http://0.0.0.0:9000/bower_components/angular-bootstrap/ui-bootstrap-tpls.js:2006:27
$modalProvider.$get</$modal.open/modalInstance.close@http://0.0.0.0:9000/bower_components/angular-bootstrap/ui-bootstrap-tpls.js:2075:17

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

Successfully merging this pull request may close these issues.

8 participants