Skip to content

Commit

Permalink
fix: validate input when the user clicks max button
Browse files Browse the repository at this point in the history
  • Loading branch information
honeymaro committed Nov 7, 2023
1 parent 98e028a commit 666d9b9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/forms/SwapForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -988,8 +988,11 @@ const SwapForm = ({ type, tabs }: { type: Type; tabs: TabViewProps }) => {
formData[Key.symbol1]
? async () => {
if (type === Type.WITHDRAW) {
setValue(Key.value1, lookup(formData[Key.max1], from))
trigger(Key.value1)
setValue(Key.value1, lookup(formData[Key.max1], from), {
shouldDirty: true,
shouldValidate: true,
shouldTouch: true,
})
return
}

Expand All @@ -1004,8 +1007,11 @@ const SwapForm = ({ type, tabs }: { type: Type; tabs: TabViewProps }) => {
}

maxBalance = lookup(maxBalance, from)
setValue(Key.value1, maxBalance)
trigger(Key.value1)
setValue(Key.value1, maxBalance, {
shouldDirty: true,
shouldValidate: true,
shouldTouch: true,
})
}
: undefined
}
Expand Down

0 comments on commit 666d9b9

Please sign in to comment.