mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-04-13 09:18:10 +00:00
chore: small ui fixes
This commit is contained in:
@@ -26,12 +26,14 @@ export const TotpForm = (props: Props) => {
|
|||||||
|
|
||||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const value = e.target.value.replace(/\D/g, "").slice(0, 6);
|
const value = e.target.value.replace(/\D/g, "").slice(0, 6);
|
||||||
form.setValue("code", value, { shouldDirty: true, shouldValidate: true });
|
form.setValue("code", value, { shouldDirty: true, shouldValidate: false });
|
||||||
if (value.length === 6) {
|
if (value.length === 6) {
|
||||||
form.handleSubmit(onSubmit)();
|
form.handleSubmit(onSubmit)();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Note: This is not the best UX, ideally we would want https://github.com/guilhermerodz/input-otp
|
||||||
|
// but some password managers cannot autofill the inputs (see #92) so, simple input it is
|
||||||
return (
|
return (
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form id={formId} onSubmit={form.handleSubmit(onSubmit)}>
|
<form id={formId} onSubmit={form.handleSubmit(onSubmit)}>
|
||||||
@@ -43,8 +45,6 @@ export const TotpForm = (props: Props) => {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
{...field}
|
{...field}
|
||||||
id="totp-code"
|
|
||||||
name="code"
|
|
||||||
type="text"
|
type="text"
|
||||||
inputMode="numeric"
|
inputMode="numeric"
|
||||||
autoComplete="one-time-code"
|
autoComplete="one-time-code"
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export const TotpPage = () => {
|
|||||||
<CardTitle className="text-xl">{t("totpTitle")}</CardTitle>
|
<CardTitle className="text-xl">{t("totpTitle")}</CardTitle>
|
||||||
<CardDescription>{t("totpSubtitle")}</CardDescription>
|
<CardDescription>{t("totpSubtitle")}</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="flex flex-col items-center">
|
<CardContent>
|
||||||
<TotpForm
|
<TotpForm
|
||||||
formId={formId}
|
formId={formId}
|
||||||
onSubmit={(values) => totpMutation.mutate(values)}
|
onSubmit={(values) => totpMutation.mutate(values)}
|
||||||
|
|||||||
Reference in New Issue
Block a user