Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sbb-alert): improve SSR hydration support #2650

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/alert/alert-group/alert-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { html, unsafeStatic } from 'lit/static-html.js';

import { SbbConnectedAbortController } from '../../core/controllers.js';
import { EventEmitter } from '../../core/eventing.js';
import { SbbHydrationMixin } from '../../core/mixins.js';
import type { SbbTitleLevel } from '../../title.js';
import { SbbAlertElement } from '../alert.js';

Expand All @@ -19,7 +20,7 @@ import style from './alert-group.scss?lit&inline';
* @event {CustomEvent<void>} empty - Emits when `sbb-alert-group` becomes empty.
*/
@customElement('sbb-alert-group')
export class SbbAlertGroupElement extends LitElement {
export class SbbAlertGroupElement extends SbbHydrationMixin(LitElement) {
public static override styles: CSSResultGroup = style;
public static readonly events = {
didDismissAlert: 'didDismissAlert',
Expand Down
1 change: 1 addition & 0 deletions src/components/core/mixins/hydration-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const SbbHydrationMixin = <T extends AbstractConstructor<LitElement>>(
// When hydration is needed, we wait the hydration process to finish, which is patched
// into the update method of the LitElement base class.
super.update(changedProperties);

if (this._hydrationRequired) {
this._hydrationRequired = false;
this._resolveHydration(true);
Expand Down
Loading