Skip to content

Commit 252c4b6

Browse files
committed
Fix typedKeyPath for list complex widgets
1 parent ac024ee commit 252c4b6

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

src/lib/components/contents/details/widgets/list/list-editor-complex.svelte

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,7 @@
479479
<FieldEditor
480480
keyPath={hasSingleSubField ? itemKeyPath : `${itemKeyPath}.${subField.name}`}
481481
typedKeyPath={hasVariableTypes
482-
? hasSingleSubField
483-
? `${keyPath}.*<${item[typeKey]}>`
484-
: `${keyPath}.*<${item[typeKey]}>.${subField.name}`
482+
? `${keyPath}.*<${item[typeKey]}>.${subField.name}`
485483
: `${keyPath}.*.${subField.name}`}
486484
{locale}
487485
fieldConfig={subField}

src/lib/components/contents/details/widgets/list/list-preview-complex.svelte

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import FieldPreview from '$lib/components/contents/details/preview/field-preview.svelte';
1313
import Subsection from '$lib/components/contents/details/widgets/object/subsection.svelte';
1414
import { entryDraft } from '$lib/services/contents/draft';
15+
import { getListFieldInfo } from '$lib/services/contents/widgets/list/helper';
1516
1617
/**
1718
* @import { WidgetPreviewProps } from '$lib/types/private';
@@ -41,6 +42,7 @@
4142
types,
4243
typeKey = 'type',
4344
} = $derived(fieldConfig);
45+
const { hasSingleSubField, hasVariableTypes } = $derived(getListFieldInfo(fieldConfig));
4446
const keyPathRegex = $derived(new RegExp(`^${escapeRegExp(keyPath)}\\.\\d+`));
4547
const items = $derived(
4648
unflatten(
@@ -69,15 +71,12 @@
6971
: (fields ?? (field ? [field] : []))}
7072
<Subsection {label}>
7173
{#each subFields as subField (subField.name)}
72-
{@const subFieldKeyPath = field ? itemKeyPath : `${itemKeyPath}.${subField.name}`}
7374
<VisibilityObserver>
7475
<FieldPreview
75-
keyPath={subFieldKeyPath}
76-
typedKeyPath={subFieldName
77-
? field
78-
? `${keyPath}.*<${subFieldName}>`
79-
: `${keyPath}.*<${subFieldName}>.${subField.name}`
80-
: subFieldKeyPath}
76+
keyPath={hasSingleSubField ? itemKeyPath : `${itemKeyPath}.${subField.name}`}
77+
typedKeyPath={hasVariableTypes
78+
? `${keyPath}.*<${subFieldName}>.${subField.name}`
79+
: `${keyPath}.*.${subField.name}`}
8180
{locale}
8281
fieldConfig={subField}
8382
/>

0 commit comments

Comments
 (0)