diff --git a/packages/core/src/__tests__/field.spec.ts b/packages/core/src/__tests__/field.spec.ts index b1c7b640003..510af2f72ec 100644 --- a/packages/core/src/__tests__/field.spec.ts +++ b/packages/core/src/__tests__/field.spec.ts @@ -1935,3 +1935,42 @@ test('field visible default value should work', () => { select.value = 'visible' expect(form.values.obj.input1).toBe('123') }) + +test('query value with sibling path syntax', () => { + const form = attach(createForm()) + const fn = jest.fn() + attach( + form.createVoidField({ + name: 'void', + }) + ) + attach( + form.createObjectField({ + name: 'obj', + basePath: 'void', + }) + ) + attach( + form.createField({ + name: 'input', + basePath: 'void.obj', + reactions: [ + (field) => { + fn( + field.query('.textarea').value(), + field.query('.textarea').initialValue() + ) + }, + ], + }) + ) + const textarea = attach( + form.createField({ + name: 'textarea', + basePath: 'void.obj', + initialValue: 'aaa', + }) + ) + textarea.value = '123' + expect(fn).toBeCalledWith('123', 'aaa') +}) diff --git a/packages/core/src/models/Query.ts b/packages/core/src/models/Query.ts index 78ee0404ed5..95256a88078 100644 --- a/packages/core/src/models/Query.ts +++ b/packages/core/src/models/Query.ts @@ -90,10 +90,10 @@ export class Query { } value() { - return this.form.getValuesIn(this.pattern) + return this.get('value') } initialValue() { - return this.form.getInitialValuesIn(this.pattern) + return this.get('initialValue') } } diff --git a/packages/element/src/checkbox/index.ts b/packages/element/src/checkbox/index.ts index d0144701f7e..b499a98822b 100644 --- a/packages/element/src/checkbox/index.ts +++ b/packages/element/src/checkbox/index.ts @@ -169,3 +169,5 @@ const CheckboxGroup = connect( export const Checkbox = composeExport(connect(CheckboxOption), { Group: CheckboxGroup, }) + +export default Checkbox