Skip to content

Commit 8b87f9a

Browse files
authored
Merge branch 'master' into issue-163-light-style-dropdown
2 parents 9991dcb + a2b61a7 commit 8b87f9a

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

src/notification/notification-display.service.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ export class NotificationDisplayService {
1111
* Programatically closes notification based on `notificationRef`. *
1212
*/
1313
close(notificationRef: any) {
14-
setTimeout(() => {
15-
this.applicationRef.detachView(notificationRef.hostView);
16-
notificationRef.destroy();
17-
}, 200);
14+
if (notificationRef.hostView) {
15+
setTimeout( () => {
16+
this.applicationRef.detachView(notificationRef.hostView);
17+
notificationRef.destroy();
18+
}, 200);
19+
}
1820
}
1921
}

src/table/table-model.class.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,4 +605,20 @@ describe("Table", () => {
605605
expect(tableModel.header[2].data).toEqual("h3");
606606
expect(tableModel.header.length).toEqual(3);
607607
});
608+
609+
it("should preserve header if data is emptied", () => {
610+
let tableModel = new TableModel();
611+
tableModel.header = [
612+
new TableHeaderItem({data: "h1"}), new TableHeaderItem({data: "h2"}), new TableHeaderItem({data: "h3"})
613+
];
614+
tableModel.data = [
615+
[new TableItem({data: "A"}), new TableItem({data: "B"}), new TableItem({data: "C"})],
616+
[new TableItem({data: "D"}), new TableItem({data: "E"}), new TableItem({data: "F"})]
617+
];
618+
tableModel.data = [[]];
619+
expect(tableModel.header.length).toEqual(3);
620+
expect(tableModel.header[0].data).toEqual("h1");
621+
expect(tableModel.header[1].data).toEqual("h2");
622+
expect(tableModel.header[2].data).toEqual("h3");
623+
});
608624
});

src/table/table-model.class.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class TableModel implements PaginationModel {
2929
this.rowsContext = new Array<string>(this._data.length);
3030

3131
// only create a fresh header if necessary (header doesn't exist or differs in length)
32-
if (this.header == null || this.header.length !== this._data[0].length) {
32+
if (this.header == null || (this.header.length !== this._data[0].length && this._data[0].length > 0)) {
3333
let header = new Array<TableHeaderItem>();
3434
for (let i = 0; i < this._data[0].length; i++) {
3535
header.push(new TableHeaderItem());

0 commit comments

Comments
 (0)