Skip to content

Commit 9b4d7f5

Browse files
committed
fix: merge default notification obj with toast content when set
Signed-off-by: Akshat Patel <[email protected]>
1 parent 06ce722 commit 9b4d7f5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/notification/toast.component.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
HostBinding
66
} from "@angular/core";
77

8+
import { of } from "rxjs";
89
import { ToastContent } from "./notification-content.interface";
910
import { NotificationDisplayService } from "./notification-display.service";
1011
import { I18n } from "carbon-components-angular/i18n";
@@ -49,7 +50,17 @@ export class Toast extends BaseNotification implements OnInit {
4950
*
5051
* `type` can be one of `"error"`, `"info"`, `"info-square"`, `"warning"`, `"warning-alt"`, or `"success"`
5152
*/
52-
@Input() notificationObj: ToastContent;
53+
@Input() set notificationObj(obj: ToastContent) {
54+
if (obj.closeLabel) {
55+
obj.closeLabel = of(obj.closeLabel);
56+
}
57+
this._notificationObj = Object.assign({}, this.defaultNotificationObj, obj);
58+
}
59+
60+
get notificationObj(): ToastContent {
61+
return this._notificationObj as ToastContent;
62+
}
63+
5364

5465
@HostBinding("attr.id") toastID = `toast-${Toast.toastCount++}`;
5566
@HostBinding("class.cds--toast-notification") toastClass = true;

0 commit comments

Comments
 (0)