Make credentials input focus logic easier to read

This commit is contained in:
dmotte 2026-05-22 19:10:08 +02:00
parent 0d82f835aa
commit 3cb3463365
1 changed files with 4 additions and 7 deletions

View File

@ -1288,16 +1288,13 @@ const UI = {
let inputFocus = "none"; let inputFocus = "none";
if (e.detail.types.indexOf("username") === -1) { if (e.detail.types.indexOf("username") === -1) {
document.getElementById("noVNC_username_block").classList.add("noVNC_hidden"); document.getElementById("noVNC_username_block").classList.add("noVNC_hidden");
} else { } else if (document.getElementById("noVNC_username_input").value === "") {
inputFocus = inputFocus === "none" && inputFocus = "noVNC_username_input";
document.getElementById("noVNC_username_input").value === ""
? "noVNC_username_input" : inputFocus;
} }
if (e.detail.types.indexOf("password") === -1) { if (e.detail.types.indexOf("password") === -1) {
document.getElementById("noVNC_password_block").classList.add("noVNC_hidden"); document.getElementById("noVNC_password_block").classList.add("noVNC_hidden");
} else { } else if (inputFocus === "none") {
inputFocus = inputFocus === "none" inputFocus = "noVNC_password_input";
? "noVNC_password_input" : inputFocus;
} }
document.getElementById('noVNC_credentials_dlg') document.getElementById('noVNC_credentials_dlg')
.classList.add('noVNC_open'); .classList.add('noVNC_open');