alibaba / alibaba/formily

[Bug Report] 基于 useField 做的 arrayItems,调用 remove 方法删除 item 时未生效

Open
#4,036 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
12.6k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

- [ ] I have searched the [issues](https://github.com/alibaba/formily/issues) of this repository and believe that this is not a duplicate.

### Reproduction link
[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/p/sandbox/formily-react-antd-markup-schema-fvpevx?file=%2FApp.tsx%3A42%2C11)

### Steps to reproduce
ArrayBase.Remove = React.forwardRef((props, ref) => {
const index = useIndex(props.index)
const self = useField()
const array = useArray()
const prefixCls = usePrefixCls('formily-array-base')
if (!array) return null
if (array.field?.pattern !== 'editable') return null
return (
{
if (self?.disabled) return
e.stopPropagation()
if (props.onClick) {
props.onClick(e)
if (e.defaultPrevented) return
}
console.log('remove inner', index);
array.field?.remove?.(index!)
array.props?.onRemove?.(index!)
}}
>
{isUndef(props.prefix) ? : props.prefix}
{props.title || self.title}

)
})

{
console.log('remove effet', index);
}
}}
>







### What is expected?
点击删除,关联 item 被销毁

### What is actually happening?
点击删除,关联 item 仍然存在

### Package
@formily/react@2.2.23

---

Contributor guide

Open the contributing guide

Research direction

Start with the CodeSandbox reproduction in App.tsx at the linked location and inspect the ArrayItems.Remove entry point shown in the report. Reproduce the click behavior with @formily/react@2.2.23, then trace whether the array field receives the item index. Done means clicking Remove destroys the associated item and the onRemove callback still receives the index.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.