Skip to content

Commit 3fe57e1

Browse files
authored
Merge branch 'master' into fix/toggle
2 parents bd1e80e + fe77085 commit 3fe57e1

File tree

5 files changed

+54
-7
lines changed

5 files changed

+54
-7
lines changed

src/dropdown/dropdown.component.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ import { I18n } from "./../i18n/i18n.module";
2828
@Component({
2929
selector: "ibm-dropdown",
3030
template: `
31-
<div class="bx--list-box">
31+
<div
32+
class="bx--list-box"
33+
[ngClass]="{'bx--dropdown--light': theme === 'light'}">
3234
<button
3335
type="button"
3436
#dropdownButton
@@ -82,7 +84,11 @@ export class Dropdown implements OnInit, AfterContentInit, OnDestroy {
8284
* item selection.
8385
*/
8486
@Input() type: "single" | "multi" = "single";
85-
87+
/**
88+
* `light` or `dark` dropdown theme
89+
* @memberof Dropdown
90+
*/
91+
@Input() theme: "light" | "dark" = "dark";
8692
/**
8793
* Set to `true` to disable the dropdown.
8894
*/

src/dropdown/dropdown.stories.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,29 @@ storiesOf("Dropdown", module)
4141
onClose: action("Dropdown closed")
4242
}
4343
}))
44+
.add("Light", () => ({
45+
template: `
46+
<ibm-dropdown
47+
theme="light"
48+
placeholder="Select"
49+
[disabled]="disabled"
50+
(selected)="selected($event)"
51+
(onClose)="onClose($event)">
52+
<ibm-dropdown-list [items]="items"></ibm-dropdown-list>
53+
</ibm-dropdown>
54+
`,
55+
props: {
56+
disabled: boolean("disabled", false),
57+
items: object("items", [
58+
{ content: "one" },
59+
{ content: "two" },
60+
{ content: "three" },
61+
{ content: "four" }
62+
]),
63+
selected: action("Selected fired for dropdown"),
64+
onClose: action("Dropdown closed")
65+
}
66+
}))
4467
.add("Multi-select", withNotes({ text: "Notes on multi select" })(() => ({
4568
template: `
4669
<ibm-dropdown

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)