Skip to content

Commit

Permalink
fix(virtual-list): fix auto height calcs in filtered items
Browse files Browse the repository at this point in the history
fixes #4168
  • Loading branch information
nolimits4web committed May 8, 2023
1 parent aa66f49 commit 1336770
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/core/components/virtual-list/virtual-list-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,18 @@ class VirtualList extends Framework7Class {
renderedItems[parseInt(el.getAttribute('data-virtual-list-index'), 10)] = el;
});
for (let i = 0; i < items.length; i += 1) {
const renderedItem = renderedItems[i];
const itemIndex = vl.items.indexOf(items[i]);
const renderedItem = renderedItems[itemIndex];
if (renderedItem) {
if (!vl.heightsCalculated.includes(i)) {
vl.heights[i] = renderedItem.offsetHeight;
vl.heightsCalculated.push(i);
if (!vl.heightsCalculated.includes(itemIndex)) {
vl.heights[itemIndex] = renderedItem.offsetHeight;
vl.heightsCalculated.push(itemIndex);
}
}
if (typeof vl.heights[i] === 'undefined') {

This comment has been minimized.

Copy link
@lokpro

lokpro May 17, 2023

Hi, you missed the i here, isn't it?

vl.heights[i] = 40;
vl.heights[itemIndex] = 40;
}
vl.listHeight += vl.heights[i];
vl.listHeight += vl.heights[itemIndex];
}
} else {
vl.listHeight = Math.ceil(items.length / vl.params.cols) * vl.params.height;
Expand Down

0 comments on commit 1336770

Please sign in to comment.