From ff4210e809c303332385ab4a985c999b77d3f4e6 Mon Sep 17 00:00:00 2001 From: StefanKoell Date: Mon, 22 Jun 2026 14:46:41 +0200 Subject: [PATCH] Fix TopMost handling for Popups on Windows (#17841) * Fix TopMost handling for Popups on Windows * Properly handle TopMost property changes * Call SetTopMost in PopupRoot constructor (similar to SetWindowManagerAddShadowHint) * Make sure the parent is focused when the popup is clicked directly to activate the app. * Move PopupsPage to IntegrationTestApp * Move Popup code to the XAML, making visual/logical management implicit * Add popup integration tests * Fix MenuTests+Default.Click_Grandchild by delaying popup activation * Kill input focus when input element on popup is focused element * try to fix tests * try to fix test v2 * Integration tests: ensure menus get closed after testing * run popup tests only on windows * WIP: Removing the hack to see if anything changes. * WIP: Removing the second hack. I'm guessing this will fix it. * fix to make transparent window integration app work on macOS * fix menu tests * Fix warning in MenuTests * Add a background to integration test popup --------- Co-authored-by: Maxwell Katz Co-authored-by: Steven Kirk Co-authored-by: Julien Lebosquain --- .../IntegrationTestApp/MainWindow.axaml.cs | 1 + .../IntegrationTestApp/Pages/PopupsPage.axaml | 70 ++++++ .../Pages/PopupsPage.axaml.cs | 48 +++++ src/Avalonia.Controls/Primitives/PopupRoot.cs | 4 + src/Windows/Avalonia.Win32/PopupImpl.cs | 6 +- .../MenuTests.cs | 65 ++++-- .../PopupsTests.cs | 199 ++++++++++++++++++ 7 files changed, 371 insertions(+), 22 deletions(-) create mode 100644 samples/IntegrationTestApp/Pages/PopupsPage.axaml create mode 100644 samples/IntegrationTestApp/Pages/PopupsPage.axaml.cs create mode 100644 tests/Avalonia.IntegrationTests.Appium/PopupsTests.cs diff --git a/samples/IntegrationTestApp/MainWindow.axaml.cs b/samples/IntegrationTestApp/MainWindow.axaml.cs index 7d6a2c2c3e..f306ce84af 100644 --- a/samples/IntegrationTestApp/MainWindow.axaml.cs +++ b/samples/IntegrationTestApp/MainWindow.axaml.cs @@ -89,6 +89,7 @@ namespace IntegrationTestApp new("ListBox", () => new ListBoxPage()), new("Menu", () => new MenuPage()), new("Pointer", () => new PointerPage()), + new("Popups", () => new PopupsPage()), new("RadioButton", () => new RadioButtonPage()), new("Screens", () => new ScreensPage()), new("ScrollBar", () => new ScrollBarPage()), diff --git a/samples/IntegrationTestApp/Pages/PopupsPage.axaml b/samples/IntegrationTestApp/Pages/PopupsPage.axaml new file mode 100644 index 0000000000..e5c4e7636f --- /dev/null +++ b/samples/IntegrationTestApp/Pages/PopupsPage.axaml @@ -0,0 +1,70 @@ + + + + +