fix(auth): prevent register modal inputs from losing focus on typing
Build and publish Docker image / build-and-publish (push) Successful in 40s
Build and publish Docker image / build-and-publish (push) Successful in 40s
This commit is contained in:
1 parent
008a3a4233
commit
ad5bf1d015
1 file changed
+100
-23
+100
-23
@@ -982,6 +982,40 @@ function ForgotPasswordModal({ onClose, colors }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Top-level input field to prevent unmounting and focus loss on re-renders
|
||||||
|
function RegisterInputField({
|
||||||
|
label,
|
||||||
|
name,
|
||||||
|
type = "text",
|
||||||
|
placeholder,
|
||||||
|
required = false,
|
||||||
|
value = '',
|
||||||
|
onChange,
|
||||||
|
disabled = false,
|
||||||
|
colors,
|
||||||
|
...props
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label className="block text-[10px] font-black uppercase tracking-[0.2em] opacity-40 ml-1">
|
||||||
|
{label} {required && '*'}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type={type}
|
||||||
|
name={name}
|
||||||
|
value={value}
|
||||||
|
onChange={onChange}
|
||||||
|
className="w-full rounded-2xl px-5 py-3.5 text-sm font-bold focus:outline-none transition-all duration-300 border bg-black/40 focus:border-primary/50 focus:ring-4 focus:ring-primary/10"
|
||||||
|
style={{ borderColor: colors.brightBlack, color: colors.brightWhite }}
|
||||||
|
placeholder={placeholder}
|
||||||
|
required={required}
|
||||||
|
disabled={disabled}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Register Modal Component - UPDATED to match Dashboard style
|
// Register Modal Component - UPDATED to match Dashboard style
|
||||||
function RegisterModal({
|
function RegisterModal({
|
||||||
onClose,
|
onClose,
|
||||||
@@ -1010,6 +1044,11 @@ function RegisterModal({
|
|||||||
[countryOptions],
|
[countryOptions],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleInputChange = useCallback((e) => {
|
||||||
|
const { name, value } = e.target;
|
||||||
|
setFormData(prev => ({ ...prev, [name]: value }));
|
||||||
|
}, []);
|
||||||
|
|
||||||
const detectUserLocation = useCallback(async () => {
|
const detectUserLocation = useCallback(async () => {
|
||||||
setDetectingLocation(true);
|
setDetectingLocation(true);
|
||||||
try {
|
try {
|
||||||
@@ -1058,23 +1097,6 @@ function RegisterModal({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const InputField = ({ label, name, type = "text", placeholder, required = false, ...props }) => (
|
|
||||||
<div className="space-y-2">
|
|
||||||
<label className="block text-[10px] font-black uppercase tracking-[0.2em] opacity-40 ml-1">{label} {required && '*'}</label>
|
|
||||||
<input
|
|
||||||
type={type}
|
|
||||||
value={formData[name]}
|
|
||||||
onChange={(e) => setFormData(prev => ({ ...prev, [name]: e.target.value }))}
|
|
||||||
className="w-full rounded-2xl px-5 py-3.5 text-sm font-bold focus:outline-none transition-all duration-300 border bg-black/40 focus:border-primary/50 focus:ring-4 focus:ring-primary/10"
|
|
||||||
style={{ borderColor: colors.brightBlack, color: colors.brightWhite }}
|
|
||||||
placeholder={placeholder}
|
|
||||||
required={required}
|
|
||||||
disabled={isLoading}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fixed inset-0 bg-black/80 backdrop-blur-sm flex items-center justify-center z-50 p-4 animate-in fade-in duration-300">
|
<div className="fixed inset-0 bg-black/80 backdrop-blur-sm flex items-center justify-center z-50 p-4 animate-in fade-in duration-300">
|
||||||
<div className="rounded-[2.5rem] w-full max-w-2xl border shadow-2xl overflow-hidden bg-dash-surfaceElevated/95 backdrop-blur-2xl animate-in zoom-in-95 duration-300 max-h-[90vh] flex flex-col"
|
<div className="rounded-[2.5rem] w-full max-w-2xl border shadow-2xl overflow-hidden bg-dash-surfaceElevated/95 backdrop-blur-2xl animate-in zoom-in-95 duration-300 max-h-[90vh] flex flex-col"
|
||||||
@@ -1094,10 +1116,45 @@ function RegisterModal({
|
|||||||
|
|
||||||
<form onSubmit={handleSubmit} className="space-y-8">
|
<form onSubmit={handleSubmit} className="space-y-8">
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
<InputField label="Username" name="username" required placeholder="User_123" />
|
<RegisterInputField
|
||||||
<InputField label="Email" name="email" type="email" required placeholder="you@example.com" />
|
label="Username"
|
||||||
<InputField label="First Name" name="firstName" placeholder="Andrzej" />
|
name="username"
|
||||||
<InputField label="Last Name" name="lastName" placeholder="Nowak" />
|
required
|
||||||
|
placeholder="User_123"
|
||||||
|
value={formData.username}
|
||||||
|
onChange={handleInputChange}
|
||||||
|
disabled={isLoading}
|
||||||
|
colors={colors}
|
||||||
|
/>
|
||||||
|
<RegisterInputField
|
||||||
|
label="Email"
|
||||||
|
name="email"
|
||||||
|
type="email"
|
||||||
|
required
|
||||||
|
placeholder="you@example.com"
|
||||||
|
value={formData.email}
|
||||||
|
onChange={handleInputChange}
|
||||||
|
disabled={isLoading}
|
||||||
|
colors={colors}
|
||||||
|
/>
|
||||||
|
<RegisterInputField
|
||||||
|
label="First Name"
|
||||||
|
name="firstName"
|
||||||
|
placeholder="Andrzej"
|
||||||
|
value={formData.firstName}
|
||||||
|
onChange={handleInputChange}
|
||||||
|
disabled={isLoading}
|
||||||
|
colors={colors}
|
||||||
|
/>
|
||||||
|
<RegisterInputField
|
||||||
|
label="Last Name"
|
||||||
|
name="lastName"
|
||||||
|
placeholder="Nowak"
|
||||||
|
value={formData.lastName}
|
||||||
|
onChange={handleInputChange}
|
||||||
|
disabled={isLoading}
|
||||||
|
colors={colors}
|
||||||
|
/>
|
||||||
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<label className="block text-[10px] font-black uppercase tracking-[0.2em] opacity-40 ml-1">Country</label>
|
<label className="block text-[10px] font-black uppercase tracking-[0.2em] opacity-40 ml-1">Country</label>
|
||||||
@@ -1135,8 +1192,28 @@ function RegisterModal({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<InputField label="Password" name="password" type="password" required placeholder="••••••••" />
|
<RegisterInputField
|
||||||
<InputField label="Confirm" name="confirmPassword" type="password" required placeholder="••••••••" />
|
label="Password"
|
||||||
|
name="password"
|
||||||
|
type="password"
|
||||||
|
required
|
||||||
|
placeholder="••••••••"
|
||||||
|
value={formData.password}
|
||||||
|
onChange={handleInputChange}
|
||||||
|
disabled={isLoading}
|
||||||
|
colors={colors}
|
||||||
|
/>
|
||||||
|
<RegisterInputField
|
||||||
|
label="Confirm"
|
||||||
|
name="confirmPassword"
|
||||||
|
type="password"
|
||||||
|
required
|
||||||
|
placeholder="••••••••"
|
||||||
|
value={formData.confirmPassword}
|
||||||
|
onChange={handleInputChange}
|
||||||
|
disabled={isLoading}
|
||||||
|
colors={colors}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
|||||||
Reference in new issue
Block a user