Fix navigation race condition with NavigateForResult
GitHub Issue (If applicable): closes https://github.com/unoplatform/uno.extensions/issues/2905
PR Type
What kind of change does this PR introduce?
- Bugfix
What is the current behavior?
When navigating from Page A to Page B with NavigateViewModelForResultAsync, if the user triggers back navigation (via NavigationBar MainCommand or hardware back button) before Page B's ViewModel finishes loading, the awaited navigation call hangs forever. The ResponseNavigator's TaskCompletionSource never completes because back navigation through Frame_Navigated event bypasses the ResponseNavigator.NavigateAsync flow.
What is the new behavior?
Back navigation now correctly completes pending ResponseNavigator instances regardless of how the navigation is triggered. The FrameNavigator.NavigatedBackAsync method checks for any pending ResponseNavigator in the service provider and completes it before restoring the previous navigator.
Changes:
-
IResponseNavigator: AddedCompleteWithResult(object?)method -
ResponseNavigator<TResult>: ImplementedCompleteWithResultas an explicit interface implementation to fix TypeLoadException when the internal interface is used across assembly boundaries. Added privateCompleteWithResultCoremethod with early-exit check for thread safety. -
FrameNavigator.NavigatedBackAsync: Detects and completes pendingResponseNavigatoron back navigation
PR Checklist
Please check if your PR fulfills the following requirements:
- [ ] Tested code with current supported SDKs
- [ ] Docs have been added/updated which fit documentation template. (for bug fixes / features)
- [ ] Unit Tests and/or UI Tests for the changes have been added (for bug fixes / features) (if applicable)
- [ ] Wasm UI Tests are not showing unexpected any differences. Validate PR
Screenshots Compare Test Runresults. - [x] Contains NO breaking changes
- [ ] Updated the Release Notes
- [x] Associated with an issue (GitHub or internal)
Other information
Internal Issue (If applicable):
💡 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.