Skip to content

Commit

Permalink
fix(sbb-notification): delay removal of notification after closing (#…
Browse files Browse the repository at this point in the history
…2333)

Currently if the notification node is removed directly after the `did-close` event is emitted, it causes an error in the React wrapper.
  • Loading branch information
kyubisation authored Jan 15, 2024
1 parent 0566d44 commit 63ba57c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/notification/notification.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert, expect, fixture } from '@open-wc/testing';
import { aTimeout, assert, expect, fixture } from '@open-wc/testing';
import { html } from 'lit/static-html.js';

import { SbbButtonElement } from '../button';
Expand Down Expand Up @@ -44,6 +44,7 @@ describe('sbb-notification', () => {

expect(element).to.have.attribute('data-state', 'closed');

await aTimeout(0);
element = document.querySelector('sbb-notification');
expect(element).to.be.null;
});
Expand Down Expand Up @@ -71,6 +72,7 @@ describe('sbb-notification', () => {

expect(element).to.have.attribute('data-state', 'closed');

await aTimeout(0);
element = document.querySelector('sbb-notification');
expect(element).to.be.null;
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/notification/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class SbbNotificationElement extends LitElement {
this._state = 'closed';
this._didClose.emit();
this._notificationResizeObserver.unobserve(this._notificationElement);
this.remove();
setTimeout(() => this.remove());
}

protected override render(): TemplateResult {
Expand Down

0 comments on commit 63ba57c

Please sign in to comment.