Skip to content

Commit 298026e

Browse files
kubafloPureWeen
authored andcommitted
[Catalyst] Adding and Removing ContextMenus currently does not work - fix (#30307)
* Disconnect context flyout handler * Update MenuFlyoutHandler.iOS.cs
1 parent 7139d79 commit 298026e

File tree

2 files changed

+1
-12
lines changed

2 files changed

+1
-12
lines changed

src/Core/src/Handlers/MenuFlyoutHandler/MenuFlyoutHandler.iOS.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,18 @@ protected override UIMenu CreatePlatformElement()
1717

1818
public void Add(IMenuElement view)
1919
{
20-
Rebuild();
2120
}
2221

2322
public void Remove(IMenuElement view)
2423
{
25-
Rebuild();
2624
}
2725

2826
public void Clear()
2927
{
30-
Rebuild();
3128
}
3229

3330
public void Insert(int index, IMenuElement view)
3431
{
35-
Rebuild();
36-
}
37-
38-
internal static void Rebuild()
39-
{
40-
// TODO: Need to figure out how to rebuild the menu items for the entire context menu. On iOS/MacCat you
41-
// can't add/remove individual menu items. You can call UIMenu.GetMenuByReplacingChildren(newChildren) to
42-
// rebuild a specific menu, but that needs to be done at the "top" (the menu itself, not individual sub-items).
43-
// https://github.com/dotnet/maui/issues/9359
4432
}
4533
}
4634
}

src/Core/src/Platform/iOS/MauiUIContextMenuInteraction.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static IUIContextMenuInteractionDelegate CreateDelegate(out IUIContextMenuIntera
3636
if (contextFlyout == null || mauiContext == null)
3737
return null;
3838

39+
contextFlyout.Handler?.DisconnectHandler();
3940
var contextFlyoutHandler = contextFlyout.ToHandler(mauiContext);
4041
var contextFlyoutPlatformView = contextFlyoutHandler.PlatformView;
4142

0 commit comments

Comments
 (0)