Skip to content

Commit

Permalink
fix(stark-ui): table - when data changes, selection is now reset
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #1366
  • Loading branch information
SuperITMan committed Jul 30, 2019
1 parent a3d8f5f commit c0d2f34
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ describe("TableComponent", () => {
expect(component.dataSource.data).toEqual([{ name: "test-data-2" }]);
});

it("should reset 'selection' when 'data' changes", () => {
component.selection.toggle({ name: "selected-data-1" });
expect(component.selection.selected).toEqual([{ name: "selected-data-1" }]);

hostComponent.dummyData = [{ name: "data-1" }];
hostFixture.detectChanges();

expect(component.selection.selected).toEqual([]);
});

it("should assign right value to isFixedHeaderEnabled when fixedHeader changes", () => {
hostComponent.fixedHeader = "true";
hostFixture.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ export class StarkTableComponent extends AbstractStarkUiComponent implements OnI
this.data = this.data || [];

if (!changes["data"].isFirstChange()) {
this._resetSelection();

if (this.resetFilterValueOnDataChange()) {
this.filterChanged.emit(this.filter);
this.applyFilter();
Expand Down

0 comments on commit c0d2f34

Please sign in to comment.