Skip to content

[Blazor] Persist component enhanced navigation state issue on components added or components updated without key #63193

Closed
1 of 1 issue completed

Description

@javiercn

_ignoreComponentPropertyValue needs to be unconditionally set outside of the loop.

https://github.com/dotnet/aspnetcore/blob/main/src/Components/Components/src/PersistentState/PersistentValueProviderComponentSubscription.cs#L148

Whenever we restore from persistent component state storage we always need to return that value instead of the one on the property.

We should cover this behavior in the unit tests for PersistentValueProviderComponentSubscription.cs

Otherwise, when a component is added, removed, then added again (for example, like what happens when we switch pages and a component gets destroyed and added back, or when a component doesn't use @key) the restored value gets ignored.

We should look at the E2E test cases in #62824 to add also support for these other two scenarios.

Specifically src/Components/test/E2ETest/Tests/StatePersistenceTest.cs and src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/PersistentState/PageWithDeclarativeEnhancedNavigationPersistentComponents.razor

Our test could be designed to use a query string to choose to render or not render the components. There would be one component without a key that renders always and a component that gets added/removed depending on the value of the query string.

In both cases the state should be restored successfully

Activity

  1. added
    area-blazor
    on Aug 8, 2025
  2. changed the title [-][Blazor] Persist component enhanced navigation state[/-] [+][Blazor] Persist component enhanced navigation state issue on components added or components updated without key[/+] on Aug 8, 2025
  3. added this to the 10.0-rc1 milestone on Aug 8, 2025
  4. javiercn commented on Aug 8, 2025

    @javiercn
    MemberAuthor

    @copilot

    We should look at the E2E test cases in #62824 to add also support for these other two scenarios.

    Specifically src/Components/test/E2ETest/Tests/StatePersistenceTest.cs and src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/PersistentState/PageWithDeclarativeEnhancedNavigationPersistentComponents.razor

    Our test could be designed to use a query string to choose to render or not render the components. There would be one component without a key that renders always and a component that gets added/removed depending on the value of the query string.

    In both cases the state should be restored successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-blazor

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions