From 5be76b1e5fcba4c3698a86822cac8a4e50ea8d78 Mon Sep 17 00:00:00 2001 From: Robert A Dixon Date: Mon, 11 Aug 2025 06:41:00 -0400 Subject: [PATCH] Fix email and password icon positioning to remain static with validation errors --- src/components/Auth/SignIn.js | 65 +++++++++--------- src/components/Auth/SignUp.js | 120 ++++++++++++++++------------------ src/styles/auth.css | 68 ++++++++----------- 3 files changed, 119 insertions(+), 134 deletions(-) diff --git a/src/components/Auth/SignIn.js b/src/components/Auth/SignIn.js index 3ce73b9..aa37044 100644 --- a/src/components/Auth/SignIn.js +++ b/src/components/Auth/SignIn.js @@ -5,7 +5,6 @@ import { useNavigate } from 'react-router-dom'; import "../../styles/auth.css"; const isStrongPassword = (password) => { - // At least one lowercase, uppercase, digit, symbol, min 8 char const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s]).{8,}$/; return regex.test(password); }; @@ -35,7 +34,7 @@ const SignIn = ({ onAuthSuccess }) => { if (!formData.password) newErrors.password = 'Password is required'; else if (!isStrongPassword(formData.password)) { - newErrors.password = + newErrors.password = 'Password must be at least 8 characters, include uppercase, lowercase, number, and symbol.'; } @@ -81,39 +80,39 @@ const SignIn = ({ onAuthSuccess }) => { required /> - {errors.email && ( -

{errors.email}

- )} +

{errors.email || ""}

- {/* PASSWORD INPUT */} + {/* PASSWORD INPUT (wrapped to keep icon anchored) */}
- - setShowPassword(!showPassword)} - role="button" - aria-label="Toggle password visibility" - tabIndex={0} - onKeyDown={(e) => - e.key === 'Enter' && setShowPassword(!showPassword) - } - data-testid="password-toggle" - > - {showPassword ? : } - - {errors.password && ( -

{errors.password}

- )} +
+ + setShowPassword(!showPassword)} + role="button" + aria-label="Toggle password visibility" + tabIndex={0} + onKeyDown={(e) => + e.key === 'Enter' && setShowPassword(!showPassword) + } + data-testid="password-toggle" + > + {showPassword ? : } + +
+ + {/* Error message placed outside the inner wrapper so it won't change wrapper height */} +

{errors.password || ""}