From 7d731af589777f078ad9b65e5d088051668af7e9 Mon Sep 17 00:00:00 2001 From: Janry Date: Wed, 11 May 2022 22:49:10 +0800 Subject: [PATCH] fix(core): fix errors filter (#3113) --- packages/core/src/__tests__/field.spec.ts | 19 +++++++++++++++++++ packages/core/src/shared/internals.ts | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/core/src/__tests__/field.spec.ts b/packages/core/src/__tests__/field.spec.ts index d9c9a361b39..c50bd7adf92 100644 --- a/packages/core/src/__tests__/field.spec.ts +++ b/packages/core/src/__tests__/field.spec.ts @@ -2188,3 +2188,22 @@ test('parent readPretty will overwrite self disabled or readOnly', () => { expect(aa.pattern).toBe('readPretty') expect(bb.pattern).toBe('editable') }) + +test('conflict name for errors filter', async () => { + const form = attach(createForm()) + const aa = attach( + form.createField({ + name: 'aa', + required: true, + }) + ) + const aa1 = attach( + form.createField({ + name: 'aa1', + required: true, + }) + ) + + await aa1.onInput('') + expect(aa.invalid).toBe(false) +}) diff --git a/packages/core/src/shared/internals.ts b/packages/core/src/shared/internals.ts index 3c464d947ed..e00f9deca40 100644 --- a/packages/core/src/shared/internals.ts +++ b/packages/core/src/shared/internals.ts @@ -656,7 +656,7 @@ export const serialize = (model: any, getter?: any) => { export const createChildrenFeedbackFilter = (field: Field) => { const identifier = field.address?.toString() return ({ address }: IFormFeedback) => { - return address.indexOf(identifier) === 0 + return address === identifier || address.indexOf(identifier + '.') === 0 } }