Skip to content

Commit

Permalink
feat(antd/next): improve copy action ui (#3263)
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Jul 11, 2022
1 parent 2ca7aaf commit fd7b5f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
11 changes: 4 additions & 7 deletions packages/antd/src/array-base/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export type ArrayBaseMixins = {
export interface IArrayBaseProps {
disabled?: boolean
onAdd?: (index: number) => void
onCopy?: (index: number) => void
onRemove?: (index: number) => void
onMoveDown?: (index: number) => void
onMoveUp?: (index: number) => void
Expand Down Expand Up @@ -222,13 +223,9 @@ ArrayBase.Copy = React.forwardRef((props, ref) => {
e.stopPropagation()
if (array.props?.disabled) return
const value = clone(array?.field?.value[index])
if (props.method === 'unshift') {
array.field?.unshift?.(value)
array.props?.onAdd?.(0)
} else {
array.field?.push?.(value)
array.props?.onAdd?.(array?.field?.value?.length - 1)
}
const distIndex = index + 1
array.field?.insert?.(distIndex, value)
array.props?.onCopy?.(distIndex)
if (props.onClick) {
props.onClick(e)
}
Expand Down
11 changes: 4 additions & 7 deletions packages/next/src/array-base/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export type ArrayBaseMixins = {

export interface IArrayBaseProps {
disabled?: boolean
onCopy?: (index: number) => void
onAdd?: (index: number) => void
onRemove?: (index: number) => void
onMoveDown?: (index: number) => void
Expand Down Expand Up @@ -250,13 +251,9 @@ ArrayBase.Copy = React.forwardRef((props, ref) => {
if (self?.disabled) return
e.stopPropagation()
const value = clone(array?.field?.value[index])
if (props.method === 'unshift') {
array.field?.unshift?.(value)
array.props?.onAdd?.(0)
} else {
array.field?.push?.(value)
array.props?.onAdd?.(array?.field?.value?.length - 1)
}
const distIndex = index + 1
array.field?.insert?.(distIndex, value)
array.props?.onCopy?.(distIndex)
if (props.onClick) {
props.onClick(e)
}
Expand Down

0 comments on commit fd7b5f5

Please sign in to comment.