Skip to content

Commit 380c5bb

Browse files
authored
feat: add autofocus to the email/username field (#16350)
this field will be automatically focused when the user sees the login screen, and it should be valid according to a11y best practices as this is the first and main element on the page fixes #16276
1 parent aabb5b7 commit 380c5bb

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/Umbraco.Web.UI.Login/src/auth.element.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const createInput = (opts: {
1919
autocomplete: AutoFill;
2020
label: string;
2121
inputmode: string;
22+
autofocus?: boolean;
2223
}) => {
2324
const input = document.createElement('input');
2425
input.type = opts.type;
@@ -28,6 +29,7 @@ const createInput = (opts: {
2829
input.required = true;
2930
input.inputMode = opts.inputmode;
3031
input.ariaLabel = opts.label;
32+
input.autofocus = opts.autofocus || false;
3133

3234
return input;
3335
};
@@ -171,6 +173,7 @@ export default class UmbAuthElement extends UmbLitElement {
171173
autocomplete: 'username',
172174
label: labelUsername,
173175
inputmode: this.usernameIsEmail ? 'email' : '',
176+
autofocus: true,
174177
});
175178
this._passwordInput = createInput({
176179
id: 'password-input',

0 commit comments

Comments
 (0)