Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
fix(mox/list): allow rerender of sorted items on arg updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jayjayjpg committed Sep 21, 2022
1 parent c014da9 commit db7a0ac
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/wicked-jars-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'mx-ui-components': patch
---

fix(mox/list): allow comp. rerender on argument updates
7 changes: 1 addition & 6 deletions addon/components/mox/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ export default class MoxListComponent extends Component {
@tracked
sortDirection;

constructor() {
super(...arguments);
this.items = this.args.items;
}

@sort('items', 'sortSetting') sortedItems;
@sort('args.items', 'sortSetting') sortedItems;

get sortSetting() {
return [`${this.sortedBy}:${this.sortDirection}`];
Expand Down
38 changes: 38 additions & 0 deletions tests/integration/components/mox/list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,42 @@ module('Integration | Component | mox/list', function(hooks) {
assert.dom(updatedListItems[3]).includesText('Fire Veil');
});
});

module('empty sortable list', function(hooks) {
hooks.beforeEach(async function() {
this.listItems = [];

await render(
hbs`
<Mox::List @items={{this.listItems}}>
<:header as |s|>
<Mox::List::Item @isHeader={{true}} @isActive={{eq s.sortedBy "name"}} @sort={{fn s.sortByColumn "name"}} data-test-name>
Name
</Mox::List::Item>
<Mox::List::Item @isHeader={{true}} @isActive={{eq s.sortedBy "description"}} @sort={{fn s.sortByColumn "description"}} data-test-description>
Description
</Mox::List::Item>
</:header>
<:body as |sortedItems|>
{{#each sortedItems as |item|}}
<Mox::List::Row>
<Mox::List::Item>
{{item.name}}
</Mox::List::Item>
<Mox::List::Item>
{{item.description}}
</Mox::List::Item>
</Mox::List::Row>
{{/each}}
</:body>
</Mox::List>
`);
});

test('it renders', function (assert) {
assert.dom('[data-test-mox-list-header]').includesText('Name');
assert.dom('[data-test-mox-list-header]').includesText('Description');
assert.dom('[data-test-mox-list-row]').doesNotExist();
});
});
});

0 comments on commit db7a0ac

Please sign in to comment.