Skip to content

Commit

Permalink
fix(reset): duplicate triggering of the click event
Browse files Browse the repository at this point in the history
  • Loading branch information
Sun79 committed Jan 9, 2024
1 parent cad9c09 commit e2f51b3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/components/src/reset/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { observer } from '@formily/reactive-vue'
import { useParentForm } from '@formily/vue'
import { Button } from 'ant-design-vue'
import { defineComponent } from 'vue'
import { defineComponent, type PropType } from 'vue'

export const Reset = observer(
defineComponent({
Expand All @@ -14,7 +14,8 @@ export const Reset = observer(
validate: {
type: Boolean,
default: false
}
},
onClick: Function as PropType<(event: MouseEvent) => void | boolean>
},
emits: ['resetValidateSuccess', 'resetValidateFailed'],
setup(props, { attrs, slots, emit }) {
Expand All @@ -25,7 +26,7 @@ export const Reset = observer(
<Button
{...attrs}
onClick={async (e) => {
const result = await (attrs as any).onClick?.(e)
const result = await props.onClick?.(e)
if (result === false) return
form
?.reset('*', {
Expand Down

0 comments on commit e2f51b3

Please sign in to comment.