Skip to content

Commit 2ac604e

Browse files
authored
Fix XamlRoot being set incorrectly in Popup Handler (#2476)
* Fix XamlRoot being set incorrectly in Popup Handler when using modal navigation in Windows * Updated `PopupSizeConstants` to not make sample app popup size too large when testing Mulitple popups page
1 parent fbfd456 commit 2ac604e

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

samples/CommunityToolkit.Maui.Sample/Models/PopupSize.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ public PopupSizeConstants(IDeviceDisplay deviceDisplay)
66
{
77
Tiny = new(100, 100);
88
Small = new(300, 300);
9-
Medium = new(0.7 * (deviceDisplay.MainDisplayInfo.Width / deviceDisplay.MainDisplayInfo.Density), 0.6 * (deviceDisplay.MainDisplayInfo.Height / deviceDisplay.MainDisplayInfo.Density));
10-
Large = new(0.9 * (deviceDisplay.MainDisplayInfo.Width / deviceDisplay.MainDisplayInfo.Density), 0.8 * (deviceDisplay.MainDisplayInfo.Height / deviceDisplay.MainDisplayInfo.Density));
9+
Medium = new(0.4 * (deviceDisplay.MainDisplayInfo.Width / deviceDisplay.MainDisplayInfo.Density), 0.6 * (deviceDisplay.MainDisplayInfo.Height / deviceDisplay.MainDisplayInfo.Density));
10+
Large = new(0.5 * (deviceDisplay.MainDisplayInfo.Width / deviceDisplay.MainDisplayInfo.Density), 0.8 * (deviceDisplay.MainDisplayInfo.Height / deviceDisplay.MainDisplayInfo.Density));
1111
}
1212

1313
// examples for fixed sizes

src/CommunityToolkit.Maui.Core/Handlers/Popup/PopUpHandler.windows.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ public static void MapOnOpened(PopupHandler handler, IPopup view, object? result
4141
ArgumentNullException.ThrowIfNull(handler.MauiContext);
4242

4343
var parent = view.Parent.ToPlatform(handler.MauiContext);
44-
4544
parent.IsHitTestVisible = false;
46-
handler.PlatformView.XamlRoot = parent.XamlRoot;
45+
handler.PlatformView.XamlRoot = view.GetWindow().Content?.Handler?.MauiContext?.GetPlatformWindow().Content.XamlRoot ?? throw new InvalidOperationException("Window Content cannot be null");
4746
handler.PlatformView.IsHitTestVisible = true;
4847
handler.PlatformView.IsOpen = true;
4948

0 commit comments

Comments
 (0)