Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObjectUnsubscribedError when md-slider removed and re-added via *ngIf #6892

Closed
TurplePurtle opened this issue Sep 6, 2017 · 3 comments · Fixed by #6907
Closed

ObjectUnsubscribedError when md-slider removed and re-added via *ngIf #6892

TurplePurtle opened this issue Sep 6, 2017 · 3 comments · Fixed by #6907
Assignees

Comments

@TurplePurtle
Copy link

Bug, feature request, or proposal:

Bug

What is the expected behavior?

The slider can be removed and added to the page by toggling the condition of an *ngIf directive on the slider itself or on a parent element/component.

What is the current behavior?

After removing the slider, and then adding it again by toggling the *ngIf off and on, an ObjectUnsubscribedError is raised.

What are the steps to reproduce?

https://embed.plnkr.co/oqhT6YMKMMKDopXfxgM7/

  1. Click "Hide slider"
  2. Click "Show slider"
  3. Error is raised, causing the slider to be rendered incorrectly.

What is the use-case or motivation for changing an existing behavior?

The current behavior breaks the page if an md-slider is inside an *ngIf.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Tested in Angular 4.4.0-RC.0, Material 2.0.0-beta.10-6b5100b, Chrome 60, TypeScript 2.1.6

Is there anything else we should know?

@rafaelss95
Copy link
Contributor

rafaelss95 commented Sep 7, 2017

Seems like your plunker is outdated (specifically zone.js version). Check it here.

@Kyderman
Copy link

Kyderman commented Sep 7, 2017

Im getting the same error on snackbar components on latest pull

@devversion devversion self-assigned this Sep 7, 2017
devversion added a commit to devversion/material2 that referenced this issue Sep 7, 2017
If a slider component will be destroyed, the `ngOnDestroy` hook calls `_directionality.change.unsubscribe()`, which means that the `unsubscribe` method is called on the `EventEmitter` instead of the actual `Subscription`. This causes the `EventEmitter` to be kind of "completed", which then means that there will be errors if `emit()` is called again (https://github.com/ReactiveX/rxjs/blob/master/src/Subject.ts#L96).

Also fixes that the drawer never unsubscribes from the `_dir.change` `EventEmitter`. This means that even if the component is destroyed, whenever the directionality changes, the drawer calls `validateDrawers()`.

Fixes angular#6892. Fixes angular#6903.
devversion added a commit to devversion/material2 that referenced this issue Sep 7, 2017
If a slider component will be destroyed, the `ngOnDestroy` hook calls `_directionality.change.unsubscribe()`, which means that the `unsubscribe` method is called on the `EventEmitter` instead of the actual `Subscription`. This causes the `EventEmitter` to be kind of "completed", which then means that there will be errors if `emit()` is called again (https://github.com/ReactiveX/rxjs/blob/master/src/Subject.ts#L96).

Also fixes that the drawer never unsubscribes from the `_dir.change` `EventEmitter`. This means that even if the component is destroyed, whenever the directionality changes, the drawer calls `validateDrawers()`.

Fixes angular#6892. Fixes angular#6903.
tinayuangao pushed a commit that referenced this issue Sep 8, 2017
)

If a slider component will be destroyed, the `ngOnDestroy` hook calls `_directionality.change.unsubscribe()`, which means that the `unsubscribe` method is called on the `EventEmitter` instead of the actual `Subscription`. This causes the `EventEmitter` to be kind of "completed", which then means that there will be errors if `emit()` is called again (https://github.com/ReactiveX/rxjs/blob/master/src/Subject.ts#L96).

Also fixes that the drawer never unsubscribes from the `_dir.change` `EventEmitter`. This means that even if the component is destroyed, whenever the directionality changes, the drawer calls `validateDrawers()`.

Fixes #6892. Fixes #6903.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants