Root SchemeName can only be set when the popover is not null (#4226)

* Root schema can only be set when the popover is not null

* Fix event selection

* Remove unnecessary null forgiving

---------

Co-authored-by: Daniel Marbach <danielmarbach@users.noreply.github.com>
Co-authored-by: Tig <tig@users.noreply.github.com>
This commit is contained in:
Daniel Marbach
2025-08-31 17:52:33 +02:00
committed by GitHub
parent 1a0f5a88b7
commit 5e7bfb8908

View File

@@ -397,10 +397,10 @@ public class MenuBarv2 : Menuv2, IDesignable
// If the active Application Popover is part of this MenuBar, hide it.
if (Application.Popover?.GetActivePopover () is PopoverMenu popoverMenu
&& popoverMenu?.Root?.SuperMenuItem?.SuperView == this)
&& popoverMenu.Root?.SuperMenuItem?.SuperView == this)
{
// Logging.Debug ($"{Title} - Calling Application.Popover?.Hide ({popoverMenu.Title})");
Application.Popover?.Hide (popoverMenu);
Application.Popover.Hide (popoverMenu);
}
if (menuBarItem is null)
@@ -416,6 +416,7 @@ public class MenuBarv2 : Menuv2, IDesignable
if (menuBarItem.PopoverMenu?.Root is { })
{
menuBarItem.PopoverMenu.Root.SuperMenuItem = menuBarItem;
menuBarItem.PopoverMenu.Root.SchemeName = SchemeName;
}
// Logging.Debug ($"{Title} - \"{menuBarItem.PopoverMenu?.Title}\".MakeVisible");
@@ -423,14 +424,15 @@ public class MenuBarv2 : Menuv2, IDesignable
menuBarItem.Accepting += OnMenuItemAccepted;
menuBarItem.PopoverMenu!.Root.SchemeName = SchemeName;
return;
void OnMenuItemAccepted (object? sender, EventArgs args)
{
// Logging.Debug ($"{Title} - OnMenuItemAccepted");
menuBarItem.PopoverMenu!.VisibleChanged -= OnMenuItemAccepted;
if (menuBarItem.PopoverMenu is { })
{
menuBarItem.PopoverMenu.VisibleChanged -= OnMenuItemAccepted;
}
if (Active && menuBarItem.PopoverMenu is { Visible: false })
{