Skip to content

Commit

Permalink
Prevent command palette from closing on right click (#9057)
Browse files Browse the repository at this point in the history
The command palette is ephemeral and is dismissed if the focus
moves to an element which is not the palette's descendant.

Unfortunately, this breaks the (right-click) context menu,
as it  is not a child of the palette
(popups are hosted on a separate root element).

(cherry picked from commit 5f8e3d1)
  • Loading branch information
Don-Vito authored and DHowett committed Feb 9, 2021
1 parent 3778924 commit 4014100
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cascadia/TerminalApp/CommandPalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,12 @@ namespace winrt::TerminalApp::implementation
void CommandPalette::_lostFocusHandler(Windows::Foundation::IInspectable const& /*sender*/,
Windows::UI::Xaml::RoutedEventArgs const& /*args*/)
{
const auto flyout = _searchBox().ContextFlyout();
if (flyout && flyout.IsOpen())
{
return;
}

auto focusedElementOrAncestor = Input::FocusManager::GetFocusedElement(this->XamlRoot()).try_as<DependencyObject>();
while (focusedElementOrAncestor)
{
Expand Down

0 comments on commit 4014100

Please sign in to comment.