eclipsesource / eclipsesource/tabris-js

Switch breaks when changing color to "initial"

Open
#2,003 0 comments 0 reactions 0 assignees View on GitHub
2.x bug ios
Dominant language
JavaScript
Stars
1.4k
Forks
171
PR merge metrics
No merged PRs in 30d

Description

### Problem description

Switch does not render and its state cannot be changed programmatically when its colors are set to `"initial"`.

Works as expected in 3.x.

### Environment

- Tabris.js version: 2.9.0
- OS: 13.3

### Code snippet

```javascript
const {Button, Switch, TextView, ui} = require('tabris');

// Create a switch with a checked handler

let MARGIN = 16;

new Switch({
left: MARGIN, top: MARGIN,
id: 'switch',
thumbOnColor: 'initial',
thumbOffColor: 'initial',
trackOnColor: 'initial',
trackOffColor: 'initial',
checked: true
}).on('checkedChanged', ({value: checked}) => {
ui.contentView.find('#stateView').first().text = checked ? 'State: checked' : 'State: unchecked';
}).appendTo(ui.contentView);

new TextView({
left: ['#switch', MARGIN], baseline: '#switch',
id: 'stateView',
text: 'State: checked'
}).appendTo(ui.contentView);

new Button({
left: MARGIN, top: ['#switch', MARGIN],
text: 'Toggle Switch'
}).on('select', () => {
let switcher = ui.contentView.find('#switch').first();
switcher.checked = !switcher.checked;
}).appendTo(ui.contentView);

```

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.