Skip to content

Commit

Permalink
fix: fix SSR of sbb-select (#2341)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB authored Jan 16, 2024
1 parent f585122 commit c46e63e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/core/dom/breakpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type Breakpoint = 'zero' | 'micro' | 'small' | 'medium' | 'wide' | 'large
*/
export function isBreakpoint(from?: Breakpoint, to?: Breakpoint): boolean {
if (!isBrowser()) {
// TODO: Maybe find better default solution for SSR?
// TODO: Remove and decide case by case what should be done on consuming end
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class SbbSelectElement extends UpdateScheduler(LitElement) {

// Wait for ssr hydration
this.startUpdate();
if (!isNextjs() || !this.hasAttribute('defer-hydration')) {
if (!isNextjs()) {
this._setupSelect();
}
}
Expand All @@ -256,7 +256,7 @@ export class SbbSelectElement extends UpdateScheduler(LitElement) {
// which is done after hydration is finished. Due to this we intercept this call
// in overriding removeAttribute to finish initialization of the sbb-select.
// https://github.com/lit/lit/blob/main/packages/react/src/create-component.ts#L293-L296
if (isNextjs() && qualifiedName === 'defer-hydration' && this.hasUpdated) {
if (isNextjs() && qualifiedName === 'defer-hydration' && !this._didLoad) {
this._setupSelect();
}
super.removeAttribute(qualifiedName);
Expand Down
1 change: 1 addition & 0 deletions src/react/core/ssr-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const withSsrDataSlotNames = <P extends object>(
Children.forEach(props.children, (child) =>
slots.add(
(typeof child === 'object' &&
!!child &&
'props' in child &&
'slot' in child.props &&
child.props.slot) ||
Expand Down

0 comments on commit c46e63e

Please sign in to comment.