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

$mdToast increases watchers but does not remove them if multiple toasts are displayed within a digest. #5193

Closed
ghost opened this issue Oct 15, 2015 · 9 comments
Assignees
Labels
needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community P1: urgent Urgent issues that should be addressed in the next minor or patch release.
Milestone

Comments

@ghost
Copy link

ghost commented Oct 15, 2015

This is kind of hard to explain, bare with me.

Using $mdToast, if you click one of the buttons to display a toast, rapidly enough so the toast does not disappear between clicks (and multiple toasts are created within 1 digest cycle), it will increase the watcher count considerably but will not remove all of the watchers for all of the toasts.

$mdToast only decreases the watchers for the last toast created within a digest cycle.

Demo: http://codepen.io/anon/pen/avLPqP

@ghost ghost changed the title $mdToast increases watchers but does not remove them if multiple ones are displayed at once. $mdToast increases watchers but does not remove them if multiple toasts are displayed within a digest. Oct 15, 2015
@ghost
Copy link
Author

ghost commented Nov 11, 2015

@ThomasBurleson please review and Triage.

@thesamchris
Copy link

Hello @robertbaker. If your problem is that the toasts are not leaving then this should solve your problem.

 var toast = $mdToast.simple()
            .content(message)
            .action(action)
            .highlightAction(false)
            .position('bottom left');
   setTimeout(function() {
      $mdToast.show(toast);
   }, 99); 

`

I encountered this problem before, where two events would trigger a toast and the second one would be left.

@ghost
Copy link
Author

ghost commented Nov 30, 2015

@samuelchristopher No that's not the issue, there is a watcher leak, nothing to do with the UI.

@EladBezalel EladBezalel added the needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community label Jan 9, 2016
@EladBezalel EladBezalel added this to the 1.0.4 milestone Jan 9, 2016
@ThomasBurleson ThomasBurleson added the P1: urgent Urgent issues that should be addressed in the next minor or patch release. label Jan 15, 2016
@ThomasBurleson ThomasBurleson modified the milestones: 1.0.4, Backlog Jan 15, 2016
@nicky-lenaers
Copy link

I encountered this issue when calling this event two times as it gets triggered twice sometimes:
$rootScope.$broadcast('http-error', res.data.message)

and listening on it:
$rootScope.$on('http-error', (event, message) => ToastService.simple(message));

For reference, the service function simple looks like:

public simple = (message) => {
    this.$mdToast.show(
        this.$mdToast.simple()
        .position('bottom right')          
        .hideDelay(1000)
        .textContent(message)
    );
}

In this case, the toast simply does not go away.

@devversion
Copy link
Member

This may be related to #6633, since multiple toasts are shown within the same interim element. When this bug is fixed, then the toasts will probably hide.

@ghost
Copy link
Author

ghost commented Mar 23, 2016

This bug is more about unattaching the events, disposing them so the number
of watchers does not increase when you display multiple toasts at the same
time, even if only one is visible.

If you open 5 toasts at the same time, the number of watchers increase but
only the last toast you opened will have the watchers removed once it
dismisses.

On Wed, Mar 23, 2016, 7:25 AM Paul Gschwendtner [email protected]
wrote:

This may be related to #6633
#6633, since multiple toasts
are shown within the same interim element. When this bug is fixed, then the
toasts will probably hide.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#5193 (comment)

@devversion
Copy link
Member

@robertbaker Exactly, and thats caused by the current interim element stack. Because we are just trashing previous element in the stack. That means, no close execution -> no event cleanup.

@EladBezalel EladBezalel modified the milestones: 1.3.0, Backlog Apr 18, 2016
@ThomasBurleson ThomasBurleson modified the milestones: 1.3.0, Backlog Apr 20, 2016
@ThomasBurleson ThomasBurleson modified the milestones: - Backlog, Deprecated May 26, 2016
@ThomasBurleson
Copy link
Contributor

This issue is closed as part of our ‘Surge Focus on Material 2' efforts.
For details, see our forum posting @ http://bit.ly/1UhZyWs.

@xplodwild
Copy link

Hitting this issue as well, has anyone got a workaround since it seems to be "deprecated"?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community P1: urgent Urgent issues that should be addressed in the next minor or patch release.
Projects
None yet
Development

No branches or pull requests

6 participants