Fixed focus lost on username input field

This commit is contained in:
2026-02-02 23:23:33 +01:00
parent 42ead722c6
commit 14c166d143
5 changed files with 20 additions and 58 deletions

View File

@@ -44,7 +44,9 @@ function setAuthUI(isAuthed) {
if (adminCard) adminCard.classList.add("hidden");
const loginUser = $("login-username");
const cachedUser = getSavedUsername();
if (loginUser && cachedUser) loginUser.value = cachedUser;
if (loginUser && cachedUser && !loginUser.dataset.userEditing && !loginUser.value) {
loginUser.value = cachedUser;
}
}
}
@@ -311,6 +313,13 @@ function setupHandlers() {
}
setAuthMode(state.authMode);
const loginUser = $("login-username");
if (loginUser) {
const markEditing = () => { loginUser.dataset.userEditing = "1"; };
["focus", "input", "keydown"].forEach(evt => loginUser.addEventListener(evt, markEditing));
loginUser.addEventListener("blur", () => { delete loginUser.dataset.userEditing; });
}
const langSelects = Array.from(document.querySelectorAll(".lang-select"));
const syncLanguageSelects = () => langSelects.forEach(sel => sel.value = getLanguage());
syncLanguageSelects();