Skip to content

Virtual Scroll does not clear elements when items are cleared and throws error #12034

@masimplo

Description

@masimplo

Ionic version: (check one with "x")
[ ] 1.x (For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1)
[ ] 2.x
[X] 3.x

I'm submitting a ... (check one with "x")
[X] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:
Add some items to a list and render them in a virtual scroll component.
Clear the list or filter the items so that the list is zero length.
virtual scroll throws error:

VM2649 virtual-util.js:315 Uncaught TypeError: Cannot read property 'top' of undefined
    at Object.updateDimensions (VM2649 virtual-util.js:315)
    at eval (VM2607 virtual-scroll.js:485)

and virtual scroll does not remove previously rendered elements

Expected behavior:

When the list is empty, virtual scroll should remove all elements

Steps to reproduce:
http://plnkr.co/edit/Zwh2jLRj2AtKATohjuk5?p=preview
Searching for 5, 55 or 555 works. Searching for 5555 (which does not exist in the list) throws error.

Related code:

insert any relevant code here

Other information:

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

global packages:

    @ionic/cli-utils : 1.4.0
    Cordova CLI      : 7.0.1
    Ionic CLI        : 3.4.0

local packages:

    @ionic/app-scripts              : 1.3.7
    @ionic/cli-plugin-cordova       : 1.4.0
    @ionic/cli-plugin-ionic-angular : 1.3.1
    Cordova Platforms               : android 6.2.3
    Ionic Framework                 : ionic-angular 3.3.0

System:

    Node       : v7.10.0
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.3 Build version 8E3004b
    ios-deploy : not installed
    ios-sim    : not installed
    npm        : 5.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions