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

Table empty when reloaded throug location.back() if window has been resized #108

Open
JoranLive opened this issue Nov 28, 2022 · 3 comments

Comments

@JoranLive
Copy link

Angular 14 / Ionic 6 / ng-table-virtual-scroll 1.3

If we go back to the page which was showing an mat-table with virtual scroll, it can appears empty.
It happens if the window has been resized before to going back.
On mobile device (ionic), it happens if the view is resized because the keyboard has been shown.

My workarround was to subscribe to location and to trigger resize event after rendering.

@JoranLive JoranLive changed the title Table empty when reloaded throug location.back() Table empty when reloaded throug location.back() if window has been resized Nov 28, 2022
@haolong7
Copy link

haolong7 commented Feb 8, 2023

Thanks for the tip, how to "trigger resize event after rendering."?

@JoranLive
Copy link
Author

window.dispatchEvent(new Event('resize'));

@EthanTuning
Copy link

window.dispatchEvent(new Event('resize'));

This was plaguing me. How the heck did you figure this out?

I was having only one case where <tr *matNoDataRow> kept rendering even though I updated the data source's data.
It was only the initial page load (and a couple other conditions were met.
If I moved my view port at all the data rows showed instantly... was super odd....

But after updating data I tacked your suggestion at the end and boom all was well.. I have absolutely no clue why this worked.

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

No branches or pull requests

3 participants