Skip to content

Commit bdf4463

Browse files
authored
fix: set proper default value in radix with content block (#4937)
User reported in discord. Radix components like accordion does not open first item by default when use with content block. The reason was in our default detection. We used indexes within ancestor and when put item inside of content block template it gets 0 but not rendered. Here improved the logic to reset index when render inside of block template. <img width="837" alt="Screenshot 2025-03-01 at 21 14 09" src="https://github.com/user-attachments/assets/788df39a-b7c5-466b-a80e-09cc40de9e3f" />
1 parent 0889342 commit bdf4463

File tree

14 files changed

+297
-216
lines changed

14 files changed

+297
-216
lines changed

apps/builder/app/builder/features/ai/ai-fetch-result.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { createRegularStyleSheet } from "@webstudio-is/css-engine";
99
import {
1010
generateJsxElement,
1111
generateJsxChildren,
12-
getIndexesWithinAncestors,
1312
idAttribute,
1413
componentAttribute,
1514
} from "@webstudio-is/react-sdk";
@@ -18,6 +17,7 @@ import {
1817
Instance,
1918
createScope,
2019
findTreeInstanceIds,
20+
getIndexesWithinAncestors,
2121
} from "@webstudio-is/sdk";
2222
import { computed } from "nanostores";
2323
import {

apps/builder/app/canvas/features/webstudio-component/webstudio-component.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ import {
2626
descendantComponent,
2727
blockComponent,
2828
blockTemplateComponent,
29+
getIndexesWithinAncestors,
2930
} from "@webstudio-is/sdk";
3031
import {
3132
idAttribute,
3233
componentAttribute,
3334
showAttribute,
3435
selectorIdAttribute,
3536
indexAttribute,
36-
getIndexesWithinAncestors,
3737
type AnyComponent,
3838
textContentAttribute,
3939
} from "@webstudio-is/react-sdk";

apps/builder/app/shared/nano-states/components.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import {
77
type Hook,
88
type HookContext,
99
namespaceMeta,
10-
getIndexesWithinAncestors,
1110
type InstanceData,
1211
} from "@webstudio-is/react-sdk";
13-
import type {
14-
Instance,
15-
WsComponentMeta,
16-
WsComponentPropsMeta,
12+
import {
13+
getIndexesWithinAncestors,
14+
type Instance,
15+
type WsComponentMeta,
16+
type WsComponentPropsMeta,
1717
} from "@webstudio-is/sdk";
1818
import type { InstanceSelector } from "../tree-utils";
1919
import { $memoryProps, $props } from "./misc";

packages/cli/src/prebuild.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { log, spinner } from "@clack/prompts";
1717
import merge from "deepmerge";
1818
import {
1919
generateWebstudioComponent,
20-
getIndexesWithinAncestors,
2120
type Params,
2221
normalizeProps,
2322
generateRemixRoute,
@@ -606,11 +605,7 @@ export const prebuild = async (options: {
606605
props,
607606
dataSources,
608607
classesMap: classes,
609-
indexesWithinAncestors: getIndexesWithinAncestors(
610-
projectMetas,
611-
instances,
612-
[rootInstanceId]
613-
),
608+
metas: projectMetas,
614609
});
615610

616611
const projectMeta = siteData.build.pages.meta;

0 commit comments

Comments
 (0)