eclipsesource / eclipsesource/tabris-js

CollectionView calls updateCell too often in iOS

Open
#2,160 0 comments 0 reactions 0 assignees View on GitHub
bug 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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.