Skip to content

fix(virtual-scroll): wrong item top calculation and visibility propagation - #17345

Merged
brandyscarney merged 14 commits into
ionic-team:masterfrom
DavidWiesner:issue-15948
Mar 26, 2019
Merged

brandyscarney merged 14 commits into
ionic-team:masterfrom
DavidWiesner:issue-15948

Conversation

@DavidWiesner

@DavidWiesner DavidWiesner commented Feb 1, 2019 •

Copy link
Copy Markdown
Contributor

Short description of what this resolves:

In the updateVDom a wrong index was used to set cells top position. This is only problematic when a headerFn or footerFn is provided.

I extended a unittest that will fail in the latest ionic version and describe this problem
https://github.com/ionic-team/ionic/blob/6603a3fe31c8b7a6dad36eac4a1b9ba849fa8ebd/core/src/components/virtual-scroll/test/virtual-scroll-utils.spec.ts#L367-L386

Detailed issue cause:
In virtual-scroll-utils.ts#L239 you are using i as overall index (including header and footer) but in virtual-scroll-utils.ts#L49 you are using the raw item index (excluding header and footer).

Also if the approxHeaderHeight perfectly matches the calculated height of the node, the visibility of the cell was not propagated to the dom.
In virtual-scroll.tsx#L330 you update the visibility of the item, but this update will only scheduled, when the height is different to the previous known height.

Changes proposed in this pull request:

  • use the right index in updateVDom to update the top transition ()
  • extend unit test to verify the top is also calculated right with a given headerFn and footerFn
  • update the visibility of the node also if a given approxHeaderHeight/approxFooterHeight matches the calculated height

Ionic Version:
4.0.2
Fixes: #15948, #17298

@ionitron-bot ionitron-bot Bot added the package: core @ionic/core package label Feb 1, 2019
@DavidWiesner DavidWiesner changed the title fix VirtualScroll itemHeight bug #15948 fix(virtual-scroll): wrong item top calculation and visibility propagation Feb 4, 2019
@DavidWiesner

Copy link
Copy Markdown
Contributor Author

You guys did a great job by rewriting virtual scroll. Both issues solved in this pr are important to fix. My company spend a lot of effort to port our three apps to ionic 4. Is there any reason why this pr will not get merged? What I can help to get this merged? Should I write another unittest or add a new unittest instead of replacing the old? Thx

@DavidWiesner

Copy link
Copy Markdown
Contributor Author

I add some more details about the causes of the issues. To help the reviewers understanding my changes.

@liamdebeasi liamdebeasi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! 🎉

@brandyscarney
brandyscarney merged commit a8a48a4 into ionic-team:master Mar 26, 2019
@brandyscarney

Copy link
Copy Markdown
Member

Thanks @DavidWiesner! I'm going to release a dev build and I'll add it to those issues for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants