Repository navigation
Description
Bug Report
Ionic Info
Run ionic info from a terminal/cmd prompt and paste the output below.
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 2.0.0-rc.6
ionic (Ionic CLI) : 4.0.0-rc.6
local packages:
@angular-devkit/core : 0.6.0
@angular-devkit/schematics : 0.6.0
@angular/cli : 6.0.1
@ionic/schematics-angular : 1.0.0-rc.6
Ionic Framework : @ionic/angular 4.0.0-alpha.7
System:
NodeJS : v8.11.2
npm : 6.0.1
OS : macOS High Sierra
Describe the Bug
ion-virtual-scroll does not load any elements when used inside an ion-tab.
Steps to Reproduce
Steps to reproduce the behavior:
- Generate a new Ionic v4 project with the
tabstemplate. - Add a
ion-virtual-scrollelement following the Ionic 4 example inside one of the tab page components. See that this virtual scroll doesn't load any children and throws no errors. - Remove the
ion-tabthat wraps theion-router-outlet - See that the virtual scroll items now load.
Related Code
This doesn't work:
<ion-tabs>
<ion-tab label="Home" icon="home" href="/tabs/(home:home)">
<ion-router-outlet name="home"></ion-router-outlet>
</ion-tab>
</ion-tabs>
This does:
<ion-tabs>
<ion-router-outlet name="home"></ion-router-outlet>
</ion-tabs>
Expected Behavior
ion-virtual-scroll should work inside of a ion-tab
Additional Context
After poking around in https://github.com/ionic-team/ionic/blob/51c2aa69a29dec1f2bb76c1b7387716b7872fd4b/core/src/components/virtual-scroll/virtual-scroll.tsx#L366. this.scrollEl.offsetHeight logs out at 0 when wrapped in the ion-tab, but returns the correct height when not. For some reason even though the ion-scroll element exists, it has 0 height when inside the ion-tab. Wrapping the onResize() method and the scrollEl.componentOnReady() callback in a setTimeout(() => {}) fixes the issue, but seems like a hacky solution.


Activity
sbannigan commentedon Jun 7, 2018
Temporary solution I'm using is adding an
ngIfto theion-virtual-scrolland setting it to true inside a setTimeout in the ionViewDidEnter() lifecycle hook:faraazc commentedon Jun 8, 2018
@manucorporat @mlynch @adamdbradley Please consider virtual-scroll + infinite scroll bugs seriously as they basic necessary feature required for the maximum data-driven Apps. Ionic 2 and 3 implementations did not justify the needs, as a result, many devs moved to native frameworks after waiting for a long time. As a community, we tried to solve this problem but with less expertise, it was hard to achieve. It will be great if V4 does not appoint and Ionic would consider VS + infinite scroll seriously and high prioritize them. This request is not just from me but from 25 other fellow devs who love Ionic and love to use Ionic for every idea/business/implementation.
Last but not least Thanks for providing Ionic which is the best gift web community has received so far.
Thanks
mlynch commentedon Jun 8, 2018
@manucorporat has made a lot of virtual scroll improvements for v4. This has been a priority for us and we hope you find it resolves a number of these issues
cptflammin commentedon Jun 12, 2018
Hi ! I cannot reproduce your example, and stripping my hair with virtualscroll and ionic 4. Would you be so kind to share your example code in order to make it working according to your comment ?
mlynch commentedon Jun 12, 2018
@gydammin are you using v4 with virtual scroll? We would LOVE your feedback. Please don't struggle in the dark here. What problems are you having?
cptflammin commentedon Jun 12, 2018
hi there!
help greatly appreciated !
Yes, I am trying to use virtualscroll with ionic 4, but struggling with the fact it seems implementation is different from ionic 3. If you have an example of implementation with ionic 4, that's would be great. Note: I generated application with tabs and modifying homepage to start with
note: data from service is ok, displayed correctly with a *ngFor
So far what I did:
export class CategoriesService {
[...]
content() : Observable<Category[]> {
// console.log(this.categories);
return of(this.categories);
}
mhartington commentedon Jun 12, 2018
@gydammin Note that virtual scroll was not setup correctly in alpha-6, meaning you could have some issues there. Try alpha-7, which should contain the right proxies needed.
For examples, we have our test case app in the Angular directory. This should have right right markup
https://github.com/ionic-team/ionic/blob/master/angular/test/testapp/src/app/virtual-scroll/virtual-scroll-page.component.ts
cptflammin commentedon Jun 14, 2018
Tested and working a breeze!
with , is it related to page lazy loading maybe?
I get however an error if replacing
According to ionic 3 doc, it should work, did smth change in between ?
cptflammin commentedon Jun 14, 2018
@mlynch @mhartington noticed the same issue as @sbannigan, but his workaround *ngIf is working.
peterramaldes commentedon Sep 23, 2018
same here!
kelvinjp commentedon Oct 21, 2018
+1
L96Github commentedon Oct 31, 2018
same issue here
cyrilcheung7925 commentedon Nov 8, 2018
same issue here +2
fix(angular): virtual-scroll
fix(angular): virtual-scroll (ionic-team#16729)
ionitron-bot commentedon Jan 12, 2019
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.