Skip to content

Commit 888dc47

Browse files
authored
fix(antd/next): fix array string field addition logic (#2998)
1 parent 18b91f8 commit 888dc47

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

packages/antd/src/array-base/index.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ const useRecord = (record?: number) => {
8585

8686
const getSchemaDefaultValue = (schema: Schema) => {
8787
if (schema?.type === 'array') return []
88-
if (schema?.type === 'boolean') return true
89-
if (schema?.type === 'date') return ''
90-
if (schema?.type === 'datetime') return ''
91-
if (schema?.type === 'number') return 0
9288
if (schema?.type === 'object') return {}
93-
if (schema?.type === 'string') return ''
94-
return null
89+
if (schema?.type === 'void') {
90+
for (let key in schema.properties) {
91+
const value = getSchemaDefaultValue(schema.properties[key])
92+
if (isValid(value)) return value
93+
}
94+
}
9595
}
9696

9797
const getDefaultValue = (defaultValue: any, schema: Schema) => {

packages/next/src/array-base/index.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ const useRecord = (record?: number) => {
8585

8686
const getSchemaDefaultValue = (schema: Schema) => {
8787
if (schema?.type === 'array') return []
88-
if (schema?.type === 'boolean') return true
89-
if (schema?.type === 'date') return ''
90-
if (schema?.type === 'datetime') return ''
91-
if (schema?.type === 'number') return 0
9288
if (schema?.type === 'object') return {}
93-
if (schema?.type === 'string') return ''
94-
return null
89+
if (schema?.type === 'void') {
90+
for (let key in schema.properties) {
91+
const value = getSchemaDefaultValue(schema.properties[key])
92+
if (isValid(value)) return value
93+
}
94+
}
9595
}
9696

9797
const getDefaultValue = (defaultValue: any, schema: Schema) => {

0 commit comments

Comments
 (0)