fix(template): using tombstoneSize for non-cached items with 0 height #1858
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1812
I have looked into the issue I had with ionic components, where the height of the virtual scroll container was wrong. (#1812)
Ionic's
ion-item
component, which I used in my example, is having an height of 0px initially, which leads to_virtualItems
being an array ofsize: 0
andcached: true
items (set in therenderingStart$
observable).Shortly after the initialization, the resize observer emits the actual height of the ionic item, and will add the difference in height to the
contentSize
(line 861). That will happen for each ionic item in my view.But before the second item difference will be calculated, the
positionByResizeObserver$
observable inpositionElements()
will callupdateElementSize()
for any further item. TheupdateElementSize()
function will then take the cached size by callinggetItemSize()
, which will replace the size of0
with thetombstoneSize
and update_virtualItems()
. After that, any further calculated differences will be wrong.Ive added a simple
|| this.tombstoneSize
to in the size ternary in updateElementSize to fix this. This could have also be added in thegetElementSize
function, but I thought it may be unexpected if that function wouldn't return the actual element size.I hope I didn't miss anything here, the autosize strategy code is actually quite complex.