UXDivers / Grial-UI-Kit-Support

This is our public repository for customers to report bugs about Grial UI Kit for Xamarin Forms
61 stars 26 forks source link

SelectableWrapPanel throws exception when try to select any item on iOS #867

Closed smartestimatorapp closed 3 months ago

smartestimatorapp commented 3 months ago

35cef961-2635-479b-9346-875f0b40ef5a report-2516795330540009999-dd74d284-83e8-4c4d-842b-04d37e509a1a.txt

Description

Steps to Reproduce

Expected Behavior

Actual Behavior

Basic Information

Screenshots

Santiago5050 commented 3 months ago

Hi @smartestimatorapp,

Thank you for reporting this issue. The crash you're experiencing with the SelectableWrapPanel inside a PopupPage is related to the Mopups library, as described in this issue.

To prevent the app from crashing, please add the following workaround code to your MauiProgram.cs file when the app is being created:

//Workaround for: https://github.com/LuckyDucko/Mopups/issues/97
#if IOS
    Mopups.Platforms.iOS.PopupPageHandler.Mapper.AppendToMapping("FixingMopupCrash", (handler, view) =>
    {
        (view as Page).Appearing += (s, e) =>
        {
            var eventName = "DescendantRemoved";
            var eventInfo = typeof(Element).GetEvent(eventName);
            var descendantRemovedEvent = typeof(Element).GetField(eventName, BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            if (descendantRemovedEvent.GetValue(view) is not Delegate eventDelegate)
            {
                return;
            }

            foreach (var d in eventDelegate.GetInvocationList())
            {
                eventInfo.RemoveEventHandler(view, d);
            }
        };
    });
#endif

Let us know if you have any questions!

Best regards