XAM-Consulting / FreshMvvm.Maui

MIT License
44 stars 10 forks source link

FreshMvvm’s ReverseInit Method Not Being Called on Second Modal Closure in MAUI App #16

Closed PenseeNumerique closed 10 months ago

PenseeNumerique commented 10 months ago

Hello,

I’m developing a MAUI application with FreshMvvm and I’m encountering an issue with the ReverseInit method. In my application, I have a search page and I’m using a modal to handle search filters. When I close the modal using PopPageModel, I go through the ReverseInit method of FreshMvvm.

However, I’m experiencing unexpected behavior: the first time I open my filter modal and close it, I go through ReverseInit just fine. But the second time I open and close the modal, without changing the page in between, ReverseInit is no longer called.

Here’s the code I use to close the modal Filter:

await CoreMethods.PopPageModel(filter, true, true);

And here’s my ReverseInit method in Search:

    public override void ReverseInit(object returnedData)
    {
        base.ReverseInit(returnedData);

        if (returnedData is Filter filter)
        {
            //Maj Filter
            Filter = filter;
        }
    }

I’m not passing null to PopPageModel, so I don’t think the issue comes from there. I’ve also checked that I don’t have multiple instances of the same page in the navigation stack.

Does anyone have an idea why ReverseInit is not called the second time I close the modal? Any help would be greatly appreciated.

Thank you in advance for your time and assistance.