adopted-ember-addons / adopted-ember-addons/ember-light-table

Ember 3.16 update breaking when table.setRows is called immediately after creating the table

Open
#744 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
311
Forks
130
PR merge metrics
No merged PRs in 30d

Description

We were updating our application to Ember 3.16 from 3.12 and found the following error thrown when the table is rendered initially. The error message is as follows.

```
Error: Assertion Failed: You attempted to update `[]` on `[object Object],
[object Object],[object Object]`, but it had already been used previously in the
same computation. Attempting to update a value after using it in a computation
can cause logical errors, infinite revalidation bugs, and performance issues,
and is not supported.

`[]` was first used:

- While rendering:
----------------
this.data
```

The error is thrown when i try to create a table by passing the `model` and then when i try to sort the table by our custom sort function and calling `table.setRows(sortedModel)`.

```
const { sortField, model, columns } = this;
const sortedModel = model.sortBy(sortField);
const table = Table.create({ columns, rows: model, enableSync: true });
const sortColumn = table.get('allColumns').findBy('valuePath', sortField);
sortColumn.setProperties({
sorted: true,
ascending: true
});
table.setRows(sortedModel); // This causes the issue
return table;
```

This was working fine until Ember 3.12. I have created a [twiddle](https://ember-twiddle.com/533f3116d27209673e549c046be13611?openFiles=components.render-table%5C.js) to reproduce the issue with minimal code possible. I think this might be similar to the issue reported in [ember-table addon](https://github.com/emberjs/ember.js/issues/18613)

Thanks

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.