[Bug Report] onFieldValueChange with array pattern not work as expected
MeetzhDing opened this issue · 2 comments
MeetzhDing commented
- I have searched the issues of this repository and believe that this is not a duplicate.
Reproduction link
Steps to reproduce
请使用这个连接地址: https://stackblitz.com/edit/formily-react-demo-z2kasa?file=src%2Fdemo%2FSchemaDemo.tsx,src%2FApp.tsx
const form = createForm({
effects: () => {
// 可以工作
// onFieldValueChange(['text1'], (field) => {
// console.log('change');
// });
// 可以工作
onFieldValueChange(/text1|input/, (field) => {
console.log('text1|input trigger');
});
// TODO 无法工作
onFieldValueChange(['input', 'text1'], (field) => {
console.log("['input','text1'] change");
});
},
});
What is expected?
FormPathPattern 类型上支持 Array, 内部看解析会变成一个字符串。应该是转化为了 path1,path2,path3
.
这个语法到底应该怎么用?文档中没有说明,感觉多个 path 的数组对这个 onFieldValueChange 更合理一些?
What is actually happening?
使用 Array 的不能工作
Package
@formily/core@2.3.0
MeetzhDing commented
@janryWang 麻烦帮忙看看这个问题,建议类型上要不然不支持数组,要不然解释清楚这个数组是做什么的。或者直接做个支持,把简单路径字符串数组,转化为 *(path1,path2,path3)
janryWang commented
这个没法改,改就是 Break Change 了,数组是路径的另一种表达,如果你要匹配多个,可以用 * 这种