Skip to content

Conversation

@MackinnonBuck
Copy link
Member

Fix NavigationLock prerendering

Fixes a bug that caused <NavigationLock /> to throw an exception during prerendering if its ConfirmExternalNavigation parameter is set to true.

Description

This bug was caused by <NavigationLock /> attempting to perform JS interop calls during prerendering. This fix moves these JS interop calls to the OnAfterRenderAsync() 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?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

We have extensive existing test coverage. New automated tests have been added for the scenario that this PR fixes.

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

@MackinnonBuck MackinnonBuck added the area-blazor Includes: Blazor, Razor Components label Sep 6, 2022
@MackinnonBuck MackinnonBuck requested a review from a team as a code owner September 6, 2022 22:36
Copy link
Member

@SteveSandersonMS SteveSandersonMS left a comment

Choose a reason for hiding this comment

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

Approving now to ensure you're not blocked, given that the implementation looks completely sufficient already. If you want to make any further tweaks as discussed I'm happy to re-review but that's up to you.

@Pilchie
Copy link
Member

Pilchie commented Sep 9, 2022

Approved for .NET 7 RC2.

@JamesNK JamesNK added this to the 7.0-rc2 milestone Sep 9, 2022
@SteveSandersonMS
Copy link
Member

@MackinnonBuck Thanks for the update - this looks great! Re-approving :)

@MackinnonBuck MackinnonBuck merged commit 5600909 into release/7.0 Sep 9, 2022
@MackinnonBuck MackinnonBuck deleted the mbuck/navigation-lock-prerendering-fix branch September 9, 2022 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants