Merge pull request #2861 from mRemoteNG/copilot/add-autofocus-to-password-field

[WIP] Add autofocus to password field on startup
This commit is contained in:
Dimitrij
2025-10-07 20:29:40 +01:00
committed by GitHub
2 changed files with 16 additions and 1 deletions

View File

@@ -61,9 +61,14 @@ namespace mRemoteNG.UI.Forms
pbLock.Image = display.ScaleImage(pbLock.Image);
Height = tableLayoutPanel1.Height;
if (NewPasswordMode) return;
if (NewPasswordMode)
{
txtPassword.Focus();
return;
}
lblVerify.Visible = false;
txtVerify.Visible = false;
txtPassword.Focus();
}
private void PasswordForm_FormClosed(object sender, FormClosedEventArgs e)

View File

@@ -45,5 +45,15 @@ namespace mRemoteNGTests.UI.Forms
cancelButton.PerformClick();
Assert.That(eventFired, Is.True);
}
[Test]
public void PasswordFieldHasAutofocus()
{
// Find the password textbox control
TextBox passwordTextBox = _passwordForm.FindControl<TextBox>("txtPassword");
// Verify that the password field has focus when the form is loaded
Assert.That(passwordTextBox.Focused, Is.True, "Password field should have autofocus when form loads");
}
}
}