Skip to content

Commit

Permalink
fix(antd/next/element): fix array base addition default value (#1913)
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang authored Jul 30, 2021
1 parent 0773b06 commit 5d88e29
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/antd/src/array-base/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AntdIconProps } from '@ant-design/icons/lib/components/AntdIcon'
import { ButtonProps } from 'antd/lib/button'
import { ArrayField } from '@formily/core'
import { useField, useFieldSchema, Schema, JSXComponent } from '@formily/react'
import { isValid } from '@formily/shared'
import { isValid, clone } from '@formily/shared'
import { SortableHandle } from 'react-sortable-hoc'
import { usePrefixCls } from '../__builtins__'
import cls from 'classnames'
Expand Down Expand Up @@ -71,7 +71,7 @@ const useIndex = (index?: number) => {
}

const getDefaultValue = (defaultValue: any, schema: Schema) => {
if (isValid(defaultValue)) return defaultValue
if (isValid(defaultValue)) return clone(defaultValue)
if (Array.isArray(schema?.items))
return getDefaultValue(defaultValue, schema.items[0])
if (schema?.items?.type === 'array') return []
Expand Down
4 changes: 2 additions & 2 deletions packages/element/src/array-base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ref,
} from '@vue/composition-api'
import { Fragment, useField, useFieldSchema, h } from '@formily/vue'
import { isValid, uid } from '@formily/shared'
import { isValid, uid, clone } from '@formily/shared'
import { ArrayField } from '@formily/core'
import { stylePrefix } from '../__builtins__/configs'

Expand Down Expand Up @@ -79,7 +79,7 @@ const useKey = () => {
}

const getDefaultValue = (defaultValue: any, schema: Schema): any => {
if (isValid(defaultValue)) return defaultValue
if (isValid(defaultValue)) return clone(defaultValue)
if (Array.isArray(schema?.items))
return getDefaultValue(defaultValue, schema.items[0])
if (schema?.items?.type === 'array') return []
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/array-base/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
PlusOutlined,
MenuOutlined,
} from '@ant-design/icons'
import { isValid } from '@formily/shared'
import { isValid, clone } from '@formily/shared'
import { AntdIconProps } from '@ant-design/icons/lib/components/AntdIcon'
import { ButtonProps } from '@alifd/next/lib/button'
import { ArrayField } from '@formily/core'
Expand Down Expand Up @@ -71,7 +71,7 @@ const useIndex = (index?: number) => {
}

const getDefaultValue = (defaultValue: any, schema: Schema) => {
if (isValid(defaultValue)) return defaultValue
if (isValid(defaultValue)) return clone(defaultValue)
if (Array.isArray(schema?.items))
return getDefaultValue(defaultValue, schema.items[0])
if (schema?.items?.type === 'array') return []
Expand Down

0 comments on commit 5d88e29

Please sign in to comment.