Repository: microsoft/terminal (language: cpp)

Issue:
Dragging a non-focused tab should make it the active tab
### Windows Terminal version

_No response_

### Windows build number

_No response_

### Other Software

_No response_

### Steps to reproduce

1. Create several terminal tabs
2. Focus on one tab to make it the current terminal view
3. Drag one of the unfocused tabs to change its order among the other tabs
4. The focus remains on the previous tab (step 2)

### Expected Behavior

Clicking on a tab to reposition it should also cause it to become the active tab.  This is how Edge works, and so this breaks a popular consistency expectation in the UI. Clicking a tab (on mousedown or dragstart) should also make that tab the active terminal.

A potentially dangerous result from this is assuming the moved tab has also made it the currently active terminal view when in fact it isn't. Typing a destructive command into that terminal may be applied to the wrong view.  In the case of several ssh sessions, possibly with many different theming colors that could make it non-obvious which tab is active, this could impact the wrong server.

 If there is a configurable setting for this, I propose the default behavior be changed to be safer. (I'd also like to know what that setting is)

### Actual Behavior

Clicking and dragging a tab to reposition it moves it in the tab bar, but leaves the active terminal view where it was rather than making the moved tab the current terminal view.


Discussion / hints:
Yea, it probably should!
I would like to work on this.
Go for it!

Fix patch:
diff --git a/src/cascadia/TerminalApp/TabManagement.cpp b/src/cascadia/TerminalApp/TabManagement.cpp
index 7acd7d3f349..c417af3c4e2 100644
--- a/src/cascadia/TerminalApp/TabManagement.cpp
+++ b/src/cascadia/TerminalApp/TabManagement.cpp
@@ -1102,6 +1102,13 @@ namespace winrt::TerminalApp::implementation
         }
 
         _rearranging = false;
+
+        if (to.has_value())
+        {
+            // Selecting the dropped tab
+            TabRow().TabView().SelectedIndex(to.value());
+        }
+
         from = std::nullopt;
         to = std::nullopt;
     }


Test patch: