Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

toast: multiple show()/hide() causes TypeError #10715

@tlaytongoogle

Description

@tlaytongoogle

Actual Behavior:

  • What is the issue? * When $mdToast.show() is called twice and then $mdToast.hide() is also called twice, all in quick succession, it results in "TypeError: Cannot read property 'remove' of undefined" and fails to hide the second toast.
  • What is the expected behavior? No TypeError should be thrown, and both toasts should be hidden.

CodePen (or steps to reproduce the issue): *

  • CodePen Demo which shows your issue: https://codepen.io/anon/pen/Xgrzxe
  • Details: It looks like an issue with $$interimElement (see https://github.com/angular/material/blob/v1.1.4/src/core/services/interimElement/interimElement.js#L291). If you show() two interim at once, the second doesn't actually show until the first is hidden. But when hide() is called, it immediately remove the latest element of 'showingInterims' for it to hide. Thus, the second hide() finds an empty showingInterims list and so produces undefined, which it tries to hide as if it were an interim, resulting in the TypeError. Meanwhile, once the first interim is actually hidden, the second one shows, having been 'missed' by the second hide().

AngularJS Versions: *

  • AngularJS Version: 1.6.4
  • AngularJS Material Version: 1.1.4

Additional Information:

  • Browser Type: * Google Chrome
  • Browser Version: * 58
  • OS: * Ubuntu
  • Stack Traces:
    TypeError: Cannot read property 'remove' of undefined
    at i (angular-material.min.js:8)
    at Object.h (angular-material.min.js:8)
    at angular-material.min.js:8
    at handleCallback (angular.js:16999)
    at angular.js:16812
    at processQueue (angular.js:16832)
    at angular.js:16876
    at Scope.$digest (angular.js:17971)
    at angular.js:18200
    at completeOutstandingRequest (angular.js:6274) "Possibly unhandled rejection: {}"
    (anonymous) @ console_runner-079c09a0e3b9ff743e39ee2d5637b9216b3545af0de366d4b9aad9dc87e26bfd.js:1
    (anonymous) @ angular.js:14525
    (anonymous) @ angular.js:11008
    processChecks @ angular.js:16858
    $digest @ angular.js:17971
    (anonymous) @ angular.js:18200
    completeOutstandingRequest @ angular.js:6274
    (anonymous) @ angular.js:6554

Shortcut to create a new CodePen Demo.
Note: * indicates required information. Without this information, your issue may be auto-closed.

Do not modify the titles or questions. Simply add your responses to the ends of the questions.
Add more lines if needed.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions