Repository navigation
Closed
Description
Bug Report
Ionic Info
Run ionic info from a terminal/cmd prompt and paste the output below.
Ionic:
ionic (Ionic CLI) : 4.1.2 (/Users/xayq-fanxl/.nvm/versions/node/v8.11.2/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.12
@angular-devkit/core : 0.7.4
@angular-devkit/schematics : 0.7.4
@angular/cli : 6.1.4
@ionic/ng-toolkit : 1.0.7
@ionic/schematics-angular : 1.0.5
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.0.0, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-webview 2.1.3, (and 17 other plugins)
System:
Android SDK Tools : 26.1.1 (/Users/xayq-fanxl/Library/Android/sdk/)
ios-deploy : 1.9.2
ios-sim : 7.0.0
NodeJS : v8.11.2 (/Users/xayq-fanxl/.nvm/versions/node/v8.11.2/bin/node)
npm : 6.1.0
OS : macOS High Sierra
Xcode : Xcode 10.0 Build version 10A255
Describe the Bug
When I use VirtualScroll, it can't render the header using the itemHeight directive.

if i delete the itemHeight and then first open the page,it was a blank page and can not render in the most time

After scroll the page, it will be rendered what i want

while scroll the list,there will always be problems with unrendering or overlapping rendering

Related Code
<ion-virtual-scroll #virtualScroll [items]="sortedItems" [headerFn]="myHeaderFn" approxHeaderHeight="30px" approxItemHeight="45px">
<ion-item-divider *virtualHeader="let header" id="scroll-letter-{{ header }}">
{{ header }}
</ion-item-divider>
<ion-item *virtualItem="let item">
<ion-label color="dark" >
<ion-text class="row-title">
{{item?.name}}
</ion-text>
</ion-label>
</ion-item>
</ion-virtual-scroll>
myHeaderFn(item, index, items) {
if (item.isDivider) {
return item.letter === 'other' ? '#' : item.letter;
} else {
return null;
}
}
myItemHeight(item: any, index: number) {
return 45;
}
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
No fields configured for issues without a type.
Activity
[-][Ionic V4.0.0-beta.13] VirtualScroll itemHeight bug[/-][+][Ionic V4.0.0-beta.12] VirtualScroll itemHeight bug[/+]Lx commentedon Nov 5, 2018
I'm also experiencing intermittent overlapping of items, especially after navigating backwards:
Lx commentedon Nov 5, 2018
Here's an example showing two separate
ion-virtual-scrollcontainers, where one is simply zero-height despite containing 20 items, and another superimposes all 21 items in the space of one item:fix VirtualScroll itemHeight bug ionic-team#15948
fix(virtual-scroll): wrong item top calculation with header or footer…
fix(virtual-scroll): wrong item top calculation with header or footer…
brandyscarney commentedon Mar 26, 2019
Thanks for the issue! This should be fixed in the
ionic 4.2.0-dev.201903262032.a8a48a4dev release. Could you please try this and let us know if it isn't fixed?lucianojdg commentedon Mar 29, 2019
I had the same problem. I can solved by setting "approxItemHeight" property
ionitron-bot commentedon Apr 28, 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.