[release/7.0] Fix NavigationLock prerendering #43785
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix
NavigationLockprerenderingFixes a bug that caused
<NavigationLock />to throw an exception during prerendering if itsConfirmExternalNavigationparameter is set totrue.Description
This bug was caused by
<NavigationLock />attempting to perform JS interop calls during prerendering. This fix moves these JS interop calls to theOnAfterRenderAsync()method, which does not get called during prerendering. This PR also adds an E2E test verifying that<NavigationLock />works correctly when prerendering is enabled.Fixes #43724
Customer Impact
The ability to cancel navigation events is a feature that the community has shown significant interest in. With it finally landing in .NET 7, we want this feature to be supported in as many scenarios as possible. The bug that this PR fixes would in many cases force customers to choose between enabling prerendering and using the
<NavigationLock />component.Regression?
Risk
We have extensive existing test coverage. New automated tests have been added for the scenario that this PR fixes.
Verification
Packaging changes reviewed?