formily icon indicating copy to clipboard operation
formily copied to clipboard

fix(core): fix void field child field reactions not work in some cases

Open coolbob1998 opened this issue 2 years ago • 0 comments

Before submitting a pull request, please make sure the following is done...

  • [X] Ensure the pull request title and commit message follow the Commit Specific in English.
  • [X] Fork the repo and create your branch from master or formily_next.
  • [X] If you've added code that should be tested, add tests!
  • [X] If you've changed APIs, update the documentation.
  • [X] Make sure your code lints (npm run lint) - we've done our best to make sure these rules match our internal linting guidelines.
  • [X] Ensure the test suite passes (npm test).

Please do not delete the above content


What have you changed?

问题

  • VoidField 的子字段,reactions 依赖在其后面渲染的字段,且获取依赖字段时使用绝对路径,联动不生效
  • field1 和 field2 的值依赖 field3,修改 field3,使用了绝对路径的 field1 联动不生效,使用相对路径的 field2 联动生效 https://codesandbox.io/s/voidfield-link-bug-dbd90f

定位

https://github.com/alibaba/formily/blob/23b94cdb026f492d65bb5d8234e5d6e52dd22ae7/packages/core/src/models/Query.ts#L17-L27

  • Formindexes 属性不是 observable,初始化通过数据路径访问 indexes 时,无法收集依赖,且也无法通过 indexes 获取节点路径

解决方案

Formindexes 设置为 observable.shallow

coolbob1998 avatar Sep 21 '22 09:09 coolbob1998