chore: small ui fixes

This commit is contained in:
Stavros
2026-04-12 18:32:59 +03:00
parent ea21cbdcd4
commit e7b44ee54e
2 changed files with 4 additions and 4 deletions

View File

@@ -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"

View File

@@ -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)}