eclipsesource / eclipsesource/tabris-js

Dispose operation executed prematurely when requested after reparenting

Open
#2,020 1 comment 0 reactions 1 assignee Claimed by @tbuschto View on GitHub
bug js
Dominant language
JavaScript
Stars
1.4k
Forks
171
PR merge metrics
No merged PRs in 30d

Description

### Problem description

When disposing a container right after its children have been moved to another container, those children will not be laid out.

It seems that the dispose operation is executed right away, before the children update is flushed.

From `_removeChild(child)`:
https://github.com/eclipsesource/tabris-js/blob/7bd6a864a0c600a0d360724ef902c94bf7fd1626/src/tabris/widgets/Composite.js#L152
From `dispose()`:
https://github.com/eclipsesource/tabris-js/blob/7bd6a864a0c600a0d360724ef902c94bf7fd1626/src/tabris/NativeObject.js#L346
### Environment

- Tabris.js version: 3.3

### Code snippet

```javascript
import { Composite, TextView, contentView } from 'tabris';

let container = ;
let thing = ;

contentView.append(
container.append(
thing
)
);

setTimeout(() => {
thing.detach();
thing.appendTo(contentView);
container.dispose(); // does not work
// setTimeout(() => container.dispose()); // works
}, 2000);
```

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.