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

bug(data-table): data source connect not called when using router #5593

Closed
benb7760 opened this issue Jul 7, 2017 · 9 comments · Fixed by #5775
Closed

bug(data-table): data source connect not called when using router #5593

benb7760 opened this issue Jul 7, 2017 · 9 comments · Fixed by #5775
Assignees
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@benb7760
Copy link

benb7760 commented Jul 7, 2017

Bug, feature request, or proposal:

I have copied the exact demo from 'material-examples' into a plunker and have loaded the TableBasicExample component via a router. When navigating to the router (via button in toolbar on plunkr), the table does not display correctly. When clicking that button again, it works. In my own application I have tested by including logging in the connect() method of the data source. It does not get called on initial navigation to the route, but it does when you navigate the second time

One resolution I have used is to perform the dataSource initialization in a setTimeout(1), which solves the issue, but I do not believe that this should be the solution.

What is the expected behavior?

The data source connect method should be called after navigating to page via router

What is the current behavior?

The data source connect method is not called

What are the steps to reproduce?

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

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

latest master, and beta8

@fiste788
Copy link

fiste788 commented Jul 8, 2017

same for me

@xbtequila
Copy link

Same here.

When calling changeDetector.detectChanges after setting the DataSource to manually trigger ChangeDetection the Table will show up.

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

@AppField
Copy link

Same here.
The workaround with changeDetector.detectChanges also works for me, but is not satisfying.

AppField pushed a commit to AppField/chronery-web that referenced this issue Jul 10, 2017
@jelbourn jelbourn added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Jul 11, 2017
heathkit added a commit to heathkit/ice-cream-fight that referenced this issue Jul 14, 2017
angular/components#5593
There's a race condition that breaks md-table on route changes. Add a
setTimeout so we trigger a second change detection after onInit.
Also run format
@niceilm
Copy link

niceilm commented Jul 17, 2017

Same here

heathkit added a commit to heathkit/ice-cream-fight that referenced this issue Jul 17, 2017
angular/components#5593
There's a race condition that breaks md-table on route changes. Add a
setTimeout so we trigger a second change detection after onInit.
Also run format
@houabidi
Copy link

Same for me !

@Potmos
Copy link

Potmos commented Aug 24, 2017

How is this Issue closed?
I mean it does have a workaround that somehow works, but the issue itself is not fixed.
At least the workaround should be mentioned on the documentation.
---- Edit
Ooops its merged, forget it.

@maxime1992
Copy link

Lost so much time figuring this out... =(

I also tried to use snapshot builds but it was not working either.

The detectChanges works but let's hope beta 9 is available with a fix soon :)

@Toub
Copy link

Toub commented Sep 14, 2017

I can confirm this hack is not necessary anymore with beta10.

@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
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.