Skip to content

Commit 318a2ed

Browse files
committed
Fix: Trigger state validation on country select
1 parent 16cd40b commit 318a2ed

File tree

1 file changed

+11
-1
lines changed
  • src/components/frame/v5/pages/UserCryptoToFiatPage/partials/ContactDetailsForm

1 file changed

+11
-1
lines changed

src/components/frame/v5/pages/UserCryptoToFiatPage/partials/ContactDetailsForm/CountrySelect.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,21 @@ export const CountrySelect = () => {
2525
country: item,
2626
}));
2727

28-
const { setValue } = useFormContext();
28+
const {
29+
setValue,
30+
trigger,
31+
formState: { isSubmitted },
32+
} = useFormContext();
2933

3034
const handleSelect = () => {
3135
// if country changed user should choose state of new country
3236
setValue('state', '');
37+
38+
// If no attempt to submit the form has been made yet, do not trigger state validation
39+
if (!isSubmitted) {
40+
return;
41+
}
42+
trigger('state');
3343
};
3444

3545
return (

0 commit comments

Comments
 (0)