diff --git a/mRemoteNG/UI/Forms/FrmPassword.cs b/mRemoteNG/UI/Forms/FrmPassword.cs index 329df7d2c..d37760dcb 100644 --- a/mRemoteNG/UI/Forms/FrmPassword.cs +++ b/mRemoteNG/UI/Forms/FrmPassword.cs @@ -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) diff --git a/mRemoteNGTests/UI/Forms/PasswordFormTests.cs b/mRemoteNGTests/UI/Forms/PasswordFormTests.cs index 9301bc370..6e1dcaedc 100644 --- a/mRemoteNGTests/UI/Forms/PasswordFormTests.cs +++ b/mRemoteNGTests/UI/Forms/PasswordFormTests.cs @@ -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("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"); + } } } \ No newline at end of file