You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Blazor] Fix Blazor persistent component state restoration for components without keys
* The value provider wasn't providing the restored value when a new component got added during an enhanced navigation update.
* The fix is to always ignore and return the restored value instead of only during the updates to the existing provider.
* Added an E2E test for updates without keys which removes the existing component and replaces it with a new instance to cover this case (it will also cover the case where a new component got added).
Copy file name to clipboardExpand all lines: src/Components/test/E2ETest/Tests/StatePersistenceTest.cs
+34-13Lines changed: 34 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -116,15 +116,22 @@ public void CanRenderComponentWithPersistedState(bool suppressEnhancedNavigation
116
116
// In each case, we validate that the state is available until the initial set of components first render reaches quiescence. Similar to how it works for Server and WebAssembly.
117
117
// For server we validate that the state is provided every time a circuit is initialized.
Copy file name to clipboardExpand all lines: src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/PersistentState/PageWithDeclarativeEnhancedNavigationPersistentComponents.razor
Copy file name to clipboardExpand all lines: src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/PersistentState/PageWithoutComponents.razor
+10-5Lines changed: 10 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -2,14 +2,19 @@
2
2
3
3
<h3>This page does not render any component. We use it to test that persisted state is only provided at the time interactive components get activated on the page.</h3>
4
4
5
-
<aid="page-with-components-link"href=@($"persistent-state/page-with-components?render-mode={RenderMode}&streaming-id={StreamingId}")>Go to page with components</a>
6
-
7
-
<aid="page-with-components-link-and-state"href=@($"persistent-state/page-with-components?render-mode={RenderMode}&streaming-id={StreamingId}&server-state=other")>Go to page with components and state</a>
8
-
9
-
<aid="page-with-components-link-and-declarative-state"href=@($"persistent-state/page-with-declarative-state-components?render-mode={RenderMode}&streaming-id={StreamingId}&server-state=other")>Go to page with declarative state components</a>
5
+
<ul>
6
+
<li><aid="page-with-components-link"href=@($"persistent-state/page-with-components?render-mode={RenderMode}&streaming-id={StreamingId}")>Go to page with components</a></li>
7
+
8
+
<li><aid="page-with-components-link-and-state"href=@($"persistent-state/page-with-components?render-mode={RenderMode}&streaming-id={StreamingId}&server-state=other")>Go to page with components and state</a></li>
9
+
10
+
<li><aid="page-with-components-link-and-declarative-state"href=@($"persistent-state/page-with-declarative-state-components?render-mode={RenderMode}&streaming-id={StreamingId}&key={KeyValue}&server-state=other")>Go to page with declarative state components</a></li>
0 commit comments