formily icon indicating copy to clipboard operation
formily copied to clipboard

[Bug Report] batch 批量赋值时字段x-visible没有正确联动

Open Grapedge opened this issue 3 years ago • 1 comments

  • [ ] I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

可见性(x-visible)联动条件:

  • fieldB: 当 fieldA 的值为 "fieldA" 时显示
  • fieldC: 当 fieldB 的值为 "fieldB" 时显示

使用 batch 赋值字段:

batch(() => {
  Object.assign(field.value, {
    fieldB: 'fieldB',
    fieldC: 'fieldC',
    fieldA: 'fieldA',
  })
})

What is expected?

期望 fieldA, fieldB, fieldC 全部展示出来

What is actually happening?

只展示了 fieldA, fieldB。

Package

@formily/[email protected]


  1. 如果不使用 batch,展示是正确的。
  2. 如果将 batch 写法里的对象 key 调整为 fieldA,fieldB,fieldC 的顺序,也是正确的(但明显不应该依赖 key 的顺序):
batch(() => {
  Object.assign(field.value, {
    fieldA: 'fieldA',
    fieldB: 'fieldB',
    fieldC: 'fieldC',
  })
})

Grapedge avatar Jan 07 '23 17:01 Grapedge

我是这样解决的 schema上 把被动改成主动 联动: fieldA: 当 fieldA 的有值为 "fieldB" 时显示 fieldB: 当 fieldB 的值为 "fieldC" 时显示

dozedoze avatar May 10 '23 06:05 dozedoze