Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fix input

Steven Tey9beadffd82ae
diff --git a/apps/web/app/app.dub.co/(auth)/register/signup-email.tsx b/apps/web/app/app.dub.co/(auth)/register/signup-email.tsx
index 15eee3b62e..17cb3d0407 100644
--- a/apps/web/app/app.dub.co/(auth)/register/signup-email.tsx
+++ b/apps/web/app/app.dub.co/(auth)/register/signup-email.tsx
@@ -18,7 +18,7 @@ export const SignUpEmail = () => {
const {
register,
handleSubmit,
- formState: { errors, isValid },
+ formState: { errors },
getValues,
setError,
} = useForm<SignUpProps>({
@@ -49,7 +49,7 @@ export const SignUpEmail = () => {
required
{...register("email")}
error={errors.email?.message}
- onChange={(e) => setError("email", { message: "" })}
+ onChange={() => setError("email", { message: "" })}
/>
<Input
type="password"
@@ -57,7 +57,7 @@ export const SignUpEmail = () => {
required
{...register("password")}
error={errors.password?.message}
- onChange={(e) => setError("password", { message: "" })}
+ onChange={() => setError("password", { message: "" })}
/>
<Button
type="submit"
diff --git a/packages/ui/src/input.tsx b/packages/ui/src/input.tsx
index d74e629b6c..87bbfb4a81 100644
--- a/packages/ui/src/input.tsx
+++ b/packages/ui/src/input.tsx
@@ -31,30 +31,46 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
{...props}
/>
- {props.error ? (
- <div className="pointer-events-none absolute inset-y-0 right-2 flex items-center">
- <AlertCircle className="size-5 flex-none text-white" fill="red" />
- </div>
- ) : type === "password" ? (
- <button
- className="absolute inset-y-0 right-0 flex items-center rounded-lg px-2.5"
- type="button"
- onClick={() => toggleIsPasswordVisible()}
- aria-label={isPasswordVisible ? "Hide password" : "Show Password"}
- >
- {isPasswordVisible ? (
- <EyeIcon
- className="size-4 flex-none text-gray-500 transition hover:text-gray-700"
- aria-hidden
+ <div className="group">
+ {props.error && (
+ <div className="pointer-events-none absolute inset-y-0 right-0 flex flex-none items-center px-2.5">
+ <AlertCircle
+ className={cn(
+ "size-5 text-white",
+ type === "password" &&
+ "transition-opacity group-hover:opacity-0",
+ )}
+ fill="#ef4444"
/>
- ) : (
- <EyeOffIcon
- className="size-4 flex-none text-gray-500 transition hover:text-gray-700"
- aria-hidden
- />
- )}
- </button>
- ) : null}
+ </div>
+ )}
+ {type === "password" && (
+ <button
+ className={cn(
+ "absolute inset-y-0 right-0 flex items-center px-3",
+ props.error &&
+ "opacity-0 transition-opacity group-hover:opacity-100",
+ )}
+ type="button"
+ onClick={() => toggleIsPasswordVisible()}
+ aria-label={
+ isPasswordVisible ? "Hide password" : "Show Password"
+ }
+ >
+ {isPasswordVisible ? (
+ <EyeIcon
+ className="size-4 flex-none text-gray-500 transition hover:text-gray-700"
+ aria-hidden
+ />
+ ) : (
+ <EyeOffIcon
+ className="size-4 flex-none text-gray-500 transition hover:text-gray-700"
+ aria-hidden
+ />
+ )}
+ </button>
+ )}
+ </div>
</div>
{props.error && (