eclipsesource / eclipsesource/tabris-js
CollectionView calls updateCell too often in iOS
- Dominant language
- JavaScript
- Stars
- 1.4k
- Forks
- 171
- PR merge metrics
- No merged PRs in 30d
Description
### Problem description
Calling `collectionView.refresh(i)` causes `updateCell` to be called multiple times.
### Expected behavior
Call it only once.
### Environment
- Tabris.js version: 3.7
- Device: iPad
OS: iOS 13.7
### Code snippet
```js
import {CollectionView, Composite, ImageView, TextView, contentView, AlertDialog, Setter} from 'tabris';
const people = [
{firstName: 'Holger', lastName: 'Staudacher'},
{firstName: 'Ian', lastName: 'Bull'},
{firstName: 'Jochen', lastName: 'Krause'},
{firstName: 'Jordi', lastName: 'Böhme López'},
{firstName: 'Markus', lastName: 'Knauer'},
{firstName: 'Moritz', lastName: 'Post'},
{firstName: 'Ralf', lastName: 'Sternberg'},
{firstName: 'Tim', lastName: 'Buschtöns'}
];
contentView.append(
{() =>
}
);
/**
* @param {Composite} cell
* @param {number} index
*/
function updateCell(cell, index) {
console.log('Updating cell ' + cell.cid);
cell.find(ImageView).only().image = `resources/${people[index].firstName.toLowerCase()}.jpg`;
cell.find(TextView).only().text = people[index].firstName;
}
/** @param {tabris.WidgetTapEvent} ev */
function handleTap({target}) {
const cv = target.parent(CollectionView);
const index = cv.itemIndex(target);
people[index].firstName = 'test';
cv.refresh(index);
}
```
Contributor guide
Assessment
This issue has not been assessed yet.