[PR #15999] Use the control that requested the context menu, instead of the active one #30799

Open
opened 2026-01-31 09:43:02 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/15999

State: closed
Merged: Yes


As mentioned in #15760

When you right-click on a non-active pane, it becomes active, but the context menu may be displayed before this happens, thus showing the Restart Connection item based the wrong pane's status.

As far as I can see, when a pane is (right)clicked:

  1. If unfocused, Focus is called. This goes through the GotFocus handler which eventually calls tab->_UpdateActivePane(sender);
  2. PointerPressed is raised which eventually shows the context menu

The first point is done asynchronously, so may update the active pane too late when the menu is already displayed (despite both end up in the UI thread).

To fix this: we plumb the control that the context menu was opened for all the way through to where the event is actually handled (in _PopulateContextMenu)

  • Tested manually
**Original Pull Request:** https://github.com/microsoft/terminal/pull/15999 **State:** closed **Merged:** Yes --- As mentioned in #15760 > > When you right-click on a non-active pane, it becomes active, but the context menu may be displayed before this happens, thus showing the Restart Connection item based the wrong pane's status. > > As far as I can see, when a pane is (right)clicked: > > 1. If unfocused, `Focus` is called. This goes through the `GotFocus` handler which eventually calls `tab->_UpdateActivePane(sender);` > 2. `PointerPressed` is raised which eventually shows the context menu > > The first point is done asynchronously, so may update the active pane too late when the menu is already displayed (despite both end up in the UI thread). To fix this: we plumb the control that the context menu was opened for all the way through to where the event is actually handled (in `_PopulateContextMenu`) * [x] Tested manually
claunia added the pull-request label 2026-01-31 09:43:02 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#30799