Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Controls/src/Core/Window/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,13 @@ void SendWindowAppearing()
void SendWindowDisppearing()
{
if (Navigation.ModalStack.Count == 0)
{
Page?.SendDisappearing();
}
else if (Navigation.ModalStack.Count > 0)
{
Navigation.ModalStack[^1]?.SendDisappearing();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, will require to update this for net standard 2.0:

/Users/builder/azdo/_work/1/s/src/Controls/src/Core/Window/Window.cs(439,27): error CS0518: Predefined type 'System.Index' is not defined or imported [/Users/builder/azdo/_work/1/s/src/Controls/src/Core/Controls.Core.csproj::TargetFramework=netstandard2.0]
/Users/builder/azdo/_work/1/s/src/Controls/src/Core/Window/Window.cs(439,27): error CS0656: Missing compiler required member 'System.Index..ctor' [/Users/builder/azdo/_work/1/s/src/Controls/src/Core/Controls.Core.csproj::TargetFramework=netstandard2.0]
    2 Error(s)
if (Navigation.ModalStack.Count > 0)
{
    Navigation.ModalStack[Navigation.ModalStack.Count - 1]?.SendDisappearing();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsuarezruiz I’ve updated the code based on your suggestion. Please let me know if you have any further concerns.

}

IsActivated = false;
}
Expand Down
22 changes: 22 additions & 0 deletions src/Controls/tests/DeviceTests/Elements/Modal/ModalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,28 @@ await CreateHandlerAndAddToWindow(window, async () =>
});
}

#if WINDOWS || MACCATALYST
[Fact]
public async Task DisappearingEventFiresWhenWindowClosedWithModal()
{
SetupBuilder();
var rootPage = new ContentPage();
var modalPage = new ContentPage();
bool disappearingTriggered = false;
modalPage.Disappearing += (_, _) => disappearingTriggered = true;
var window = new Window(rootPage);
await rootPage.Navigation.PushModalAsync(modalPage);

await CreateHandlerAndAddToWindow<IWindowHandler>(window, async handler =>
{
await OnLoadedAsync(modalPage);
Application.Current?.CloseWindow(window);
});

Assert.True(disappearingTriggered);
}
#endif

class PageTypes : IEnumerable<object[]>
{
public IEnumerator<object[]> GetEnumerator()
Expand Down
Loading