eclipsesource / eclipsesource/tabris-js

TabFolder and Picker fire selection events on creation

Open
#1,494 0 comments 0 reactions 0 assignees View on GitHub
bug windows
Dominant language
JavaScript
Stars
1.4k
Forks
171
PR merge metrics
No merged PRs in 30d

Description

### Problem description
Upon initialization of a TabFolder with Tabs and a Picker with items:

||`"select"`|`"selectionChanged"/"selectionIndexChanged"`|
|---|---|---|
|TabFolder|y|y|
|Picker|n|y (twice) |

When creating a TabFolder with Tabs, both its `"select"` nor `"selectionChanged"` events are fired.

When creating a Picker with items, its `"selectionIndexChanged"` event is fired twice.

### Expected behavior

Since the Picker and the TabFolder were initialized with their selections, they haven't been selected yet and their selection didn't change. I propose to suppress all initial events related to selection.

||`"select"`|`"selectionChanged"/"selectionIndexChanged"`|
|---|---|---|
|TabFolder|n|n|
|Picker|n|n|

### Environment

- Tabris.js version: 2.1
- OS: Windows 10 Mobile

### Code snippet

```javascript
const {Picker, Tab, TabFolder, ui} = require('tabris');

const AIRPORTS = [
{id: 'SFO', name: 'San Francisco'},
{id: 'TXL', name: 'Berlin Tegel'},
{id: 'FRA', name: 'Frankfurt'}
];

new Picker({
left: 20, top: 20, right: 20,
itemCount: AIRPORTS.length,
itemText: (index) => AIRPORTS[index].name
}).on('select', () => console.log('Picker: select fired'))
.on('selectionIndexChanged', () => console.log('Picker: selectionIndexChanged fired'))
.appendTo(ui.contentView);

let tabFolder = new TabFolder({
left: 20, top: 'prev() 8', right: 20
}).on('select', () => console.log('TabFolder: select fired'))
.on('selectionChanged', () => console.log('TabFolder: selectionChanged fired'))
.appendTo(ui.contentView);

new Tab({title: 'Tab1'}).appendTo(tabFolder);
new Tab({title: 'Tab2'}).appendTo(tabFolder);
```

### Related
Related iOS and Android issue: #1495

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.