Skip to content

Commit c65f502

Browse files
authored
fix(ui): ensure field components safely access field.admin property (#7670)
1 parent dc496e4 commit c65f502

File tree

18 files changed

+25
-21
lines changed

18 files changed

+25
-21
lines changed

packages/richtext-lexical/src/field/Field.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const RichTextComponent: React.FC<
4040
readOnly: readOnlyFromAdmin,
4141
style,
4242
width,
43-
},
43+
} = {},
4444
label,
4545
required,
4646
},

packages/richtext-lexical/src/field/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const RichTextEditor = lazy(() =>
1717

1818
export const RichTextField: React.FC<LexicalRichTextFieldProps> = (props) => {
1919
const {
20-
admin,
20+
admin = {},
2121
field: { richTextComponentMap },
2222
lexicalEditorConfig,
2323
} = props

packages/richtext-slate/src/field/RichText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const RichTextField: React.FC<LoadedSlateFieldProps> = (props) => {
6464
readOnly: readOnlyFromAdmin,
6565
style,
6666
width,
67-
},
67+
} = {},
6868
label,
6969
required,
7070
},

packages/ui/src/fields/Array/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const ArrayFieldComponent: React.FC<ArrayFieldProps> = (props) => {
4343
description,
4444
isSortable = true,
4545
readOnly: readOnlyFromAdmin,
46-
},
46+
} = {},
4747
fields,
4848
label,
4949
localized,

packages/ui/src/fields/Blocks/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const BlocksFieldComponent: React.FC<BlockFieldProps> = (props) => {
4242
field: {
4343
name,
4444
_path: pathFromProps,
45-
admin: { className, description, isSortable = true, readOnly: readOnlyFromAdmin },
45+
admin: { className, description, isSortable = true, readOnly: readOnlyFromAdmin } = {},
4646
blocks,
4747
label,
4848
labels: labelsFromProps,

packages/ui/src/fields/Code/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const CodeFieldComponent: React.FC<CodeFieldProps> = (props) => {
3737
readOnly: readOnlyFromAdmin,
3838
style,
3939
width,
40-
},
40+
} = {},
4141
label,
4242
required,
4343
},

packages/ui/src/fields/Collapsible/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const CollapsibleFieldComponent: React.FC<CollapsibleFieldProps> = (props) => {
2727
field,
2828
field: {
2929
_path: pathFromProps,
30-
admin: { className, description, initCollapsed = false, readOnly: readOnlyFromAdmin },
30+
admin: { className, description, initCollapsed = false, readOnly: readOnlyFromAdmin } = {},
3131
fields,
3232
label,
3333
},

packages/ui/src/fields/DateTime/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const DateTimeFieldComponent: React.FC<DateFieldProps> = (props) => {
3535
readOnly: readOnlyFromAdmin,
3636
style,
3737
width,
38-
},
38+
} = {},
3939
label,
4040
required,
4141
},

packages/ui/src/fields/Group/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const GroupFieldComponent: React.FC<GroupFieldProps> = (props) => {
3232
descriptionProps,
3333
field,
3434
field: {
35-
admin: { className, description, hideGutter, readOnly: readOnlyFromAdmin, style, width },
35+
admin: { className, description, hideGutter, readOnly: readOnlyFromAdmin, style, width } = {},
3636
fields,
3737
label,
3838
},

packages/ui/src/fields/JSON/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ const JSONFieldComponent: React.FC<JSONFieldProps> = (props) => {
2525
field: {
2626
name,
2727
_path: pathFromProps,
28-
admin: { className, description, editorOptions, readOnly: readOnlyFromAdmin, style, width },
28+
admin: {
29+
className,
30+
description,
31+
editorOptions,
32+
readOnly: readOnlyFromAdmin,
33+
style,
34+
width,
35+
} = {},
2936
jsonSchema,
3037
label,
3138
required,

0 commit comments

Comments
 (0)