Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion components/Send/SendForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const SendForm: React.FC<SendFormProps> = ({ onNext }) => {
handleSubmit,
formState: { errors, isValid },
setValue,
trigger,
} = useForm({
resolver: zodResolver(sendSchema),
mode: Platform.OS === 'web' ? 'onChange' : undefined,
Expand Down Expand Up @@ -155,7 +156,12 @@ const SendForm: React.FC<SendFormProps> = ({ onNext }) => {
const maxAmount = formatUnits(balanceWei, liveToken.contractDecimals);
setAmount(maxAmount);
setValue('amount', maxAmount);
}, [setAmount, setValue, liveToken, balanceWei]);
// RHF's onChange mode validates on the Controller's input change event,
// not on programmatic setValue. Without an explicit trigger, isValid
// stays at its prior value and Review stays disabled when the user
// hits Max without typing first.
trigger('amount');
}, [setAmount, setValue, trigger, liveToken, balanceWei]);

const onSubmit = useCallback(
(data: any) => {
Expand Down
Loading