Skip to content

Commit 254a705

Browse files
CopilotGitHub Copilotmfranzkemichaelmkraus
authored
fix: DBSection ignoring id prop during SSR (#5582)
* Initial plan * Fix DBSection to use id prop directly for SSR compatibility * Remove unused imports and state from DBSection * refactor: remove unused DBSectionState and GlobalState from model.ts * Create six-oranges-kneel.md * feat: pass id to react-, angular- and vue-component * feat: remove debugging output --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Maximilian Franzke <[email protected]> Co-authored-by: michaelmkraus <[email protected]>
1 parent 1133c21 commit 254a705

File tree

7 files changed

+20
-28
lines changed

7 files changed

+20
-28
lines changed

.changeset/six-oranges-kneel.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@db-ux/ngx-core-components": patch
3+
"@db-ux/react-core-components": patch
4+
"@db-ux/wc-core-components": patch
5+
"@db-ux/v-core-components": patch
6+
---
7+
8+
fix: DBSection ignoring `id` prop during SSR
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
ContainerWidthProps,
33
GlobalProps,
4-
GlobalState,
54
SpacingProps
65
} from '../../shared/model';
76

@@ -11,7 +10,3 @@ export type DBSectionProps = DBSectionDefaultProps &
1110
GlobalProps &
1211
SpacingProps &
1312
ContainerWidthProps;
14-
15-
export type DBSectionDefaultState = {};
16-
17-
export type DBSectionState = DBSectionDefaultState & GlobalState;

packages/components/src/components/section/section.lite.tsx

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,17 @@
1-
import {
2-
onMount,
3-
useDefaultProps,
4-
useMetadata,
5-
useRef,
6-
useStore
7-
} from '@builder.io/mitosis';
8-
import { DEFAULT_ID } from '../../shared/constants';
9-
import { cls, uuid } from '../../utils';
10-
import { DBSectionProps, DBSectionState } from './model';
1+
import { useDefaultProps, useMetadata, useRef } from '@builder.io/mitosis';
2+
import { cls } from '../../utils';
3+
import { DBSectionProps } from './model';
114

125
useMetadata({});
136
useDefaultProps<DBSectionProps>({});
147

158
export default function DBSection(props: DBSectionProps) {
169
const _ref = useRef<HTMLDivElement | any>(null);
17-
// jscpd:ignore-start
18-
const state = useStore<DBSectionState>({
19-
_id: DEFAULT_ID
20-
});
21-
22-
onMount(() => {
23-
state._id = props.id || 'section-' + uuid();
24-
});
25-
// jscpd:ignore-end
2610

2711
return (
2812
<section
2913
ref={_ref}
30-
id={state._id}
14+
id={props.id}
3115
class={cls('db-section', props.className)}
3216
data-spacing={props.spacing || 'medium'}
3317
data-width={props.width}>

showcases/angular-showcase/src/app/components/section/section.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
class="db-color-informational db-bg-color-basic-level-2 section-card-container"
1515
[spacing]="exampleProps?.spacing"
1616
[width]="exampleProps?.width"
17+
[id]="exampleProps?.id"
1718
>
1819
<db-card>{{ exampleName }}</db-card>
1920
<db-card>{{ exampleName }}</db-card>

showcases/react-showcase/src/components/section/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import { type BaseComponentProps } from '../base-component-data';
55
import { getVariants } from '../data';
66
import DefaultComponent from '../default-component';
77

8-
const getSection = ({ width, spacing, children }: DBSectionProps) => (
8+
const getSection = ({ width, spacing, children, id }: DBSectionProps) => (
99
<DBSection
1010
className="db-color-informational db-bg-color-basic-level-2 section-card-container"
1111
spacing={spacing}
12-
width={width}>
12+
width={width}
13+
id={id}>
1314
<DBCard>{children}</DBCard>
1415
<DBCard>{children}</DBCard>
1516
<DBCard>{children}</DBCard>

showcases/shared/section.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
{
66
"name": "Functional",
77
"density": "functional",
8-
"props": {}
8+
"props": {
9+
"id": "test-id-123"
10+
}
911
},
1012
{
1113
"name": "(Default) Regular",

showcases/vue-showcase/src/components/section/Section.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import DefaultComponent from "../DefaultComponent.vue";
1313
class="db-color-informational db-bg-color-basic-level-2 section-card-container"
1414
:spacing="exampleProps?.spacing"
1515
:width="exampleProps?.width"
16+
:id="exampleProps?.id"
1617
>
1718
<DBCard>{{ exampleName }}</DBCard>
1819
<DBCard>{{ exampleName }}</DBCard>

0 commit comments

Comments
 (0)