Skip to content

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

@javiercn

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

Sub-issues

Metadata

Metadata

Assignees

Labels

area-blazorIncludes: Blazor, Razor Components

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions