lucacivale / Maui.BottomSheet

Native BottomSheets in .Net Maui!
MIT License
34 stars 4 forks source link

Closed event call just after the BottomSheet is already closed #11

Closed adrianotrentim closed 1 month ago

adrianotrentim commented 1 month ago

I am having problems using the component with the following situation.

I'm using the component to create a menu, as an option to ToolBarItem, since iOS doesn't render these menus correctly like Android.

The problem is that when I execute a command from this menu, I want the BottomSheet to be closed, and call a certain action.

In this action, I have a call to a popup that displays a loading frame.

The problem is that, when calling this popup, it is shown over the BottomSheet. And I even understand why, since it is a View.

I tried using this command call within the BottomSheet's Closed event, but this event is called when the BottomSheet is still present on the screen.

Is there any possibility of the Closed event being called when the BottomSheet is already closed?

lucacivale commented 1 month ago

Can you give me a repro for that?

adrianotrentim commented 1 month ago

It is very complex to reproduce because it involves other plugins.

But basically, as the Opened and Closed events are called when the BottomSheet is still open, anything you need to do, that needs to show a popup for example, considers the view to be the BottomSheet itself, not the page itself.

Take a look at PR 12 and see if you agree

adrianotrentim commented 1 month ago

but if you want to simulate do the following. 1 - Create a project, add CommunityToolKit 2 - Create a page and add the BottomSheet with a button inside, linked to any command on the page. 3 - In this command, create a CommunityToolkit popup, to load it in the same command. You will notice that the popup will be "inside" the BottomSheet.

To prevent this, create an event in the Closed of the BottomSheet, that is, so that when closing, the popup is called within the page, no longer within the BottomSheet.

This would be the logic, but it doesn't work, because the Closed event is called when the BottomSheed is still visible

adrianotrentim commented 1 month ago

forgive my English, I'm Brazilian and I don't speak English very well

lucacivale commented 1 month ago

@adrianotrentim thank you for your PR. This should be fixed and I'll release a new version asap.