Skip to content

Conversation

@SyedAbdulAzeemSF4852
Copy link
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details

  • When navigating to a new ShellItem using a route like //SomeRoute/SomePage, and SomePage specifies Shell.PresentationMode="Modal", the page’s OnAppearing event is called twice.

Root Cause

  • During Shell navigation between different ShellItems (e.g., //tab1 to //tab2/modal), modal pages receive duplicate lifecycle events because the old ShellSection calls SendDisappearing() on the modal page during its cleanup, but the modal page now belongs to the new ShellSection, which also manages its lifecycle events.

Description of Change

  • Added an IsVisibleSection check in PresentedPageDisappearingmethod to ensure lifecycle events are only sent by the active ShellSection. This prevents duplicate events on modal pages during ShellItem transitions by blocking non-visible (previous) ShellSections from managing pages they no longer own.

Issues Fixed

Fixes #31584

Validated the behaviour in the following platforms

  • Windows
  • Android
  • iOS
  • Mac

Output

Platform Before After
iOS
iOS_Before.mov
iOS_After.mov
Android
Android_Before.mov
Android_After.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Nov 13, 2025
@dotnet-policy-service
Copy link
Contributor

Hey there @@SyedAbdulAzeemSF4852! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Nov 13, 2025
@sheiksyedm sheiksyedm marked this pull request as ready for review November 17, 2025 14:38
Copilot AI review requested due to automatic review settings November 17, 2025 14:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where OnAppearing is called twice on modal pages when navigating between different ShellItems in .NET MAUI Shell. The fix adds a check to prevent non-visible ShellSections from sending lifecycle events to pages they no longer own.

Key changes:

  • Modified PresentedPageDisappearing() in ShellSection.cs to check IsVisibleSection before sending disappearing events to modal pages
  • Added UI test case to verify the fix prevents duplicate OnAppearing calls during ShellItem transitions with modal pages

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Controls/src/Core/Shell/ShellSection.cs Added IsVisibleSection check in PresentedPageDisappearing() to prevent duplicate lifecycle events on modal pages during ShellItem transitions
src/Controls/tests/TestCases.HostApp/Issues/Issue31584.cs Added HostApp test page demonstrating the bug and verifying the fix with modal navigation between ShellItems
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31584.cs Added NUnit UI test to verify modal page OnAppearing is triggered only once during ShellItem navigation

@sheiksyedm
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Member

/rebase

@PureWeen
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

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

Can you rework this to just be a unit test vs a UItest?

I think we can validate this purely by being a UITest?

@PureWeen
Copy link
Member

Conversation_Summary_PR_32582.md

@SyedAbdulAzeemSF4852 @sheiksyedm

I had copilot add unit tests based on your UITest

I asked it this

"The PR here #32582 is using a UITest can you instead make this a unit test? Please make sure to validate that the test fails without the changes and then it's fixed with the changes. Feel free to add any additional tests."

and then it generated these tests

Please review added tests and delete UITests if they look good

@SyedAbdulAzeemSF4852
Copy link
Contributor Author

Conversation_Summary_PR_32582.md

@SyedAbdulAzeemSF4852 @sheiksyedm

I had copilot add unit tests based on your UITest

I asked it this

"The PR here #32582 is using a UITest can you instead make this a unit test? Please make sure to validate that the test fails without the changes and then it's fixed with the changes. Feel free to add any additional tests."

and then it generated these tests

Please review added tests and delete UITests if they look good

@PureWeen , I’ve gone through the tests Copilot added. Two of the tests seemed quite similar and were essentially testing the same thing, so I’ve removed one of them. I’ve also removed the original UI test since the remaining unit tests provide the necessary coverage.

@sheiksyedm
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Member

/rebase

@PureWeen
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen changed the base branch from main to inflight/current November 20, 2025 09:40
@PureWeen PureWeen merged commit 0e7b379 into dotnet:inflight/current Nov 20, 2025
154 of 163 checks passed
github-actions bot pushed a commit that referenced this pull request Nov 20, 2025
…m change with PresentationMode set to Modal (#32582)

* Fix for Page OnAppearing triggered twice when navigating via ShellItem change with PresentationMode set to Modal

* - generate tests with copilot

* Removed the UI test since unit tests have been added, and also removed duplicate tests in the unit tests

---------

Co-authored-by: Shane Neuville <[email protected]>
PureWeen added a commit that referenced this pull request Nov 21, 2025
…m change with PresentationMode set to Modal (#32582)

* Fix for Page OnAppearing triggered twice when navigating via ShellItem change with PresentationMode set to Modal

* - generate tests with copilot

* Removed the UI test since unit tests have been added, and also removed duplicate tests in the unit tests

---------

Co-authored-by: Shane Neuville <[email protected]>
github-actions bot pushed a commit that referenced this pull request Nov 24, 2025
…m change with PresentationMode set to Modal (#32582)

* Fix for Page OnAppearing triggered twice when navigating via ShellItem change with PresentationMode set to Modal

* - generate tests with copilot

* Removed the UI test since unit tests have been added, and also removed duplicate tests in the unit tests

---------

Co-authored-by: Shane Neuville <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Page's OnAppearing triggered twice with ShellItemChanged + PresentationMode Modal combo

3 participants