Skip to content

Commit

Permalink
fix(core): onInput not ignore when currentTarget is undefined (#3862)
Browse files Browse the repository at this point in the history
  • Loading branch information
frehaiku authored Jun 19, 2023
1 parent 44f0810 commit 1e49061
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/core/src/__tests__/field.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2361,4 +2361,8 @@ test('onInput should ignore HTMLInputEvent propagation', async () => {

await aa.onInput({ target: { value: '2' }, currentTarget: { value: '4' } })
expect(aa.value).toEqual('321')

// currentTarget is undefined, skip ignore
await aa.onInput({ target: { value: '123' } })
expect(aa.value).toEqual('123')
})
2 changes: 1 addition & 1 deletion packages/core/src/models/Field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ export class Field<

onInput = async (...args: any[]) => {
const isHTMLInputEventFromSelf = (args: any[]) =>
isHTMLInputEvent(args[0])
isHTMLInputEvent(args[0]) && 'currentTarget' in args[0]
? args[0]?.target === args[0]?.currentTarget
: true
const getValues = (args: any[]) => {
Expand Down

0 comments on commit 1e49061

Please sign in to comment.