Skip to content

Commit af3bff8

Browse files
authored
fix(experience): display loading spinner on submit buttons when navigating to user app (#7675)
1 parent 2a2abce commit af3bff8

File tree

7 files changed

+13
-14
lines changed

7 files changed

+13
-14
lines changed

packages/experience/src/containers/SetPassword/Lite.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ const Lite = ({ className, autoFocus, onSubmit, errorMessage, clearErrorMessage
4242
}, [clearErrorMessage, isValid]);
4343

4444
const onSubmitHandler = useCallback(
45-
(event?: React.FormEvent<HTMLFormElement>) => {
45+
async (event?: React.FormEvent<HTMLFormElement>) => {
4646
clearErrorMessage?.();
4747

48-
void handleSubmit(async (data) => {
48+
await handleSubmit(async (data) => {
4949
await onSubmit(data.newPassword);
5050
})(event);
5151
},

packages/experience/src/containers/SetPassword/SetPassword.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ const SetPassword = ({
5656
}, [clearErrorMessage, isValid]);
5757

5858
const onSubmitHandler = useCallback(
59-
(event?: React.FormEvent<HTMLFormElement>) => {
59+
async (event?: React.FormEvent<HTMLFormElement>) => {
6060
clearErrorMessage?.();
6161

62-
void handleSubmit(async (data) => {
62+
await handleSubmit(async (data) => {
6363
await onSubmit(data.newPassword);
6464
})(event);
6565
},

packages/experience/src/pages/Continue/ExtraProfileForm/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import useValidateField from './use-validate-field';
1515
type Props = {
1616
readonly customProfileFields: CustomProfileField[];
1717
readonly defaultValues?: Record<string, unknown>;
18-
readonly onSubmit: (values: Record<string, unknown>) => void;
18+
readonly onSubmit: (values: Record<string, unknown>) => Promise<void>;
1919
};
2020

2121
const ExtraProfileForm = ({ customProfileFields, defaultValues, onSubmit }: Props) => {
@@ -32,11 +32,11 @@ const ExtraProfileForm = ({ customProfileFields, defaultValues, onSubmit }: Prop
3232
formState: { errors, isValid, isSubmitting },
3333
} = methods;
3434

35-
const submit = handleSubmit((value) => {
35+
const submit = handleSubmit(async (value) => {
3636
if (!isValid) {
3737
return;
3838
}
39-
onSubmit(value);
39+
await onSubmit(value);
4040
});
4141

4242
return (
@@ -80,7 +80,6 @@ const ExtraProfileForm = ({ customProfileFields, defaultValues, onSubmit }: Prop
8080
);
8181
})}
8282
<Button title="action.continue" htmlType="submit" isLoading={isSubmitting} />
83-
8483
<input hidden type="submit" />
8584
</form>
8685
</FormProvider>

packages/experience/src/pages/Continue/IdentifierProfileForm/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ const IdentifierProfileForm = ({
6161
}, [clearErrorMessage, isValid]);
6262

6363
const onSubmitHandler = useCallback(
64-
(event?: React.FormEvent<HTMLFormElement>) => {
64+
async (event?: React.FormEvent<HTMLFormElement>) => {
6565
clearErrorMessage?.();
6666

67-
void handleSubmit(async ({ identifier: { type, value } }) => {
67+
await handleSubmit(async ({ identifier: { type, value } }) => {
6868
if (!type) {
6969
return;
7070
}

packages/experience/src/pages/ForgotPassword/ForgotPasswordForm/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const ForgotPasswordForm = ({ className, autoFocus, defaultValue = '', enabledTy
6161
async (event?: React.FormEvent<HTMLFormElement>) => {
6262
clearErrorMessage();
6363

64-
void handleSubmit(async ({ identifier: { type, value } }) => {
64+
await handleSubmit(async ({ identifier: { type, value } }) => {
6565
if (!type) {
6666
return;
6767
}

packages/experience/src/pages/MfaVerification/BackupCodeVerification/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ const BackupCodeVerification = () => {
2929
} = useForm<FormState>({ defaultValues: { code: '' } });
3030

3131
const onSubmitHandler = useCallback(
32-
(event?: FormEvent<HTMLFormElement>) => {
33-
void handleSubmit(async ({ code }) => {
32+
async (event?: FormEvent<HTMLFormElement>) => {
33+
await handleSubmit(async ({ code }) => {
3434
await sendMfaPayload({
3535
flow: UserMfaFlow.MfaVerification,
3636
payload: { type: MfaFactor.BackupCode, code },

packages/experience/src/pages/SignInPassword/PasswordForm/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const PasswordForm = ({
7070
async (event?: React.FormEvent<HTMLFormElement>) => {
7171
clearErrorMessage();
7272

73-
void handleSubmit(async ({ identifier: { type, value }, password }) => {
73+
await handleSubmit(async ({ identifier: { type, value }, password }) => {
7474
if (!type) {
7575
return;
7676
}

0 commit comments

Comments
 (0)