Skip to content

Commit 745e433

Browse files
fix(client): unique collapse id for inspector state tree
1 parent 11876c8 commit 745e433

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

packages/client/src/components/inspector/InspectorState.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ createStateEditorContext({
3131
{{ name }}
3232
</span>
3333
</div>
34-
<InspectorStateType v-if="isExpanded" :data="data" />
34+
<InspectorStateType v-if="isExpanded" :data="data" :root-id="id" />
3535
</template>

packages/client/src/components/inspector/InspectorStateField.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const props = withDefaults(defineProps<{
1010
data: InspectorState
1111
depth?: number
1212
no: number
13+
rootId: string
1314
}>(), {
1415
depth: 0,
1516
})
@@ -26,7 +27,7 @@ const stateFormatClass = computed(() => {
2627
return ``
2728
})
2829
29-
const { isExpanded, toggleCollapse } = useCollapse('inspector-state', `${props.no}-${props.depth}-${props.data.key}`)
30+
const { isExpanded, toggleCollapse } = useCollapse('inspector-state', `${props.rootId}-${props.no}-${props.depth}-${props.data.key}`)
3031
3132
const normalizedValue = computed(() => {
3233
const stateTypeName = (props.data as InspectorCustomState)._custom?.stateTypeName || props.data?.stateTypeName
@@ -208,7 +209,7 @@ const { isHovering } = useHover(containerRef)
208209
</div>
209210
<div v-if="isExpanded">
210211
<InspectorStateField
211-
v-for="(field, index) in normalizedChildField" :key="index" :data="field" :depth="depth + 1" :no="no"
212+
v-for="(field, index) in normalizedChildField" :key="index" :data="field" :depth="depth + 1" :no="no" :root-id="rootId"
212213
/>
213214
<div v-if="draftingNewProp.enable" :style="{ paddingLeft: `${(depth + 1) * 15 + 4}px` }">
214215
<span overflow-hidden text-ellipsis whitespace-nowrap state-key>

packages/client/src/components/inspector/InspectorStateType.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { InspectorState } from '@vue/devtools-kit'
44
withDefaults(defineProps<{
55
data: InspectorState[]
66
depth?: number
7+
rootId: string
78
}>(), {
89
depth: 0,
910
})
@@ -14,6 +15,6 @@ withDefaults(defineProps<{
1415
v-for="(item, index) in data"
1516
:key="index" class="flex items-center pl-8 font-data-field"
1617
>
17-
<InspectorStateField :data="item" :no="index" />
18+
<InspectorStateField :data="item" :no="index" :root-id="rootId" />
1819
</div>
1920
</template>

0 commit comments

Comments
 (0)