-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
Virtual Scroll fix: this.approxItemHeight is undefined when update(true) is called first #8350
Virtual Scroll fix: this.approxItemHeight is undefined when update(true) is called first #8350
Conversation
Hello @ckaeslin, thanks for the PR! How can I reproduce this? Is it random or is there something I can do to always get an error? :) |
This one is pretty easy to reproduce, use the lates Ionic2 RC0 and create a virtual-scroll (without
Or checkout this repo https://github.com/jeromeXoo/ionic2.rc0.Virtual-Scroll-Not-Working and remove you will just get a blank page (and an error message: TypeError: Cannot read property 'indexOf' of undefined) |
Documentation says approxItemHeight is default set to 40px: http://ionicframework.com/docs/v2/api/components/virtual-scroll/VirtualScroll/#input-properties |
Interestingly enough, this error goes away if you move the data out of the constructor into the
While we don't recommend loading data in the constructor of your component, throwing an error isn't a good alternative so I'll look into your PR. Thanks again! |
@brandyscarney , sorry, it still happens.
|
The problem is that https://github.com/driftyco/ionic/blob/master/src/components/virtual-scroll/virtual-scroll.ts#L346 goes to https://github.com/driftyco/ionic/blob/master/src/components/virtual-scroll/virtual-util.ts#L569, where approxItemHeight is not defined, because it's currently done after |
Look good! Thanks 👍 |
Short description of what this resolves:
this.approxItemHeight is undefined when update(true) is called first
see #8311
Changes proposed in this pull request:
Ionic Version: 2.1.0
Fixes: #8311