Merge pull request #2924 from mRemoteNG/copilot/fix-first-connection-panel-issue

Fix connection panel visibility issue on first connection
This commit is contained in:
Dimitrij
2025-10-16 21:45:50 +01:00
committed by GitHub
3 changed files with 13 additions and 3 deletions

View File

@@ -320,7 +320,8 @@ namespace mRemoteNG.Connection
ConnectionWindow connectionForm = conForm ?? Runtime.WindowList.FromString(connectionPanel) as ConnectionWindow;
if (connectionForm == null)
connectionForm = _panelAdder.AddPanel(connectionPanel);
// Don't show the panel immediately - it will be shown when first tab is added
connectionForm = _panelAdder.AddPanel(connectionPanel, showImmediately: false);
else
connectionForm.Show(FrmMain.Default.pnlDock);

View File

@@ -15,14 +15,17 @@ namespace mRemoteNG.UI.Panels
[SupportedOSPlatform("windows")]
public class PanelAdder
{
public ConnectionWindow AddPanel(string title = "")
public ConnectionWindow AddPanel(string title = "", bool showImmediately = true)
{
try
{
ConnectionWindow connectionForm = new(new DockContent());
BuildConnectionWindowContextMenu(connectionForm);
SetConnectionWindowTitle(title, connectionForm);
ShowConnectionWindow(connectionForm);
// Only show immediately if requested (for user-created empty panels)
// When opening connections, we defer showing until first tab is added
if (showImmediately)
ShowConnectionWindow(connectionForm);
PrepareTabSupport(connectionForm);
return connectionForm;
}

View File

@@ -143,6 +143,12 @@ namespace mRemoteNG.UI.Window
// TODO: See if we can make this work with DPS...
//TabController.HideTabsMode = TabControl.HideTabsModes.HideAlways;
// Ensure the ConnectionWindow is visible before adding the tab
// This prevents visibility issues when the window was created but not yet shown
if (!Visible)
{
Show(FrmMain.Default.pnlDock, DockState.Document);
}
//Show the tab
conTab.Show(connDock, DockState.Document);