-
Notifications
You must be signed in to change notification settings - Fork 0
Fix erratic Page.Loaded events in Shell tab navigation #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: SuthiYuvaraj <92777079+SuthiYuvaraj@users.noreply.github.com>
Co-authored-by: SuthiYuvaraj <92777079+SuthiYuvaraj@users.noreply.github.com>
| this.Window is null; // user has set the main page to a different shell instance | ||
| } | ||
|
|
||
| // Additional check: Don't disconnect if we're just switching between tabs in the same section |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite these changes, the Loaded event is still triggered multiple times , this issue occurs only on Android.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've implemented an Android-specific fix to address the multiple Loaded events issue. The problem was that Android's Fragment lifecycle in Shell navigation causes ViewAttachedToWindow/ViewDetachedFromWindow events to fire multiple times during tab switching, even with the initial ShellContent fix.
The solution adds platform-specific tracking in VisualElement to prevent redundant Loaded events by:
- Tracking the last platform view instance to detect genuine view changes vs fragment lifecycle events
- Only firing Loaded events when switching to a genuinely new platform view or transitioning from unloaded state
- Clearing the tracked view on handler changes and unload events
This should resolve the Android-specific multiple Loaded events while maintaining the cross-platform fix for Shell disconnect logic. Commit: 64ade55
Co-authored-by: SuthiYuvaraj <92777079+SuthiYuvaraj@users.noreply.github.com>
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!
Description
This PR fixes erratic Page.Loaded events in Shell navigation when using FlyoutItem/Tab/ShellContent scenarios. The issue manifested as:
Root Cause
The
EvaluateDisconnect()method inShellContent.cswas too aggressive in disconnecting page caches during tab navigation within the same ShellItem. This caused unnecessary page recreation and multiple Loaded events as pages were being disconnected and recreated on every tab switch.Solution
Enhanced the
EvaluateDisconnect()logic to be more conservative by:Before
After
Testing
The fix ensures that:
Fixes dotnet#11.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
4zjvsblobprodcus390.vsblob.vsassets.iodotnet build src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.