Skip to content

Commit 5bdbc57

Browse files
authored
Autofocus 1st field in login form (#7304)
1 parent f132e23 commit 5bdbc57

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The login form now automatically focuses on the first field.

frontend/app/src/entities/authentication/ui/login.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ export const LoginForm = ({ className }: { className?: string }) => {
5858
await login(data);
5959
}}
6060
>
61-
<InputField name="username" label="Username" rules={{ validate: { required: isRequired } }} />
61+
<InputField
62+
name="username"
63+
label="Username"
64+
rules={{ validate: { required: isRequired } }}
65+
autoFocus
66+
/>
6267

6368
<PasswordInputField
6469
name="password"

frontend/app/src/shared/components/form/fields/input.field.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const InputField = ({
2929
unique,
3030
pool,
3131
isBulkUpdate,
32+
autoFocus,
3233
...props
3334
}: InputFieldProps) => {
3435
return (
@@ -62,7 +63,7 @@ const InputField = ({
6263
onChange={(event) => {
6364
field.onChange(updateFormFieldValue(event.target.value, defaultValue));
6465
}}
65-
autoFocus={override}
66+
autoFocus={autoFocus || override}
6667
onBlur={() => setOverride(false)}
6768
/>
6869
) : (

0 commit comments

Comments
 (0)