Scroll in enhanced navigation behaves same as in client side routing#60296
Scroll in enhanced navigation behaves same as in client side routing#60296ilonatommy merged 26 commits intodotnet:mainfrom
Conversation
…d scroll position.
… and enhanced nav handle the history produced by onDocumentClick.
There was a problem hiding this comment.
Copilot reviewed 5 out of 9 changed files in this pull request and generated 1 comment.
Files not reviewed (4)
- src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/EnhancedNav/PageForScrollPositionTests.razor: Evaluated as low risk
- src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/EnhancedNav/PageForScrollPositionTestsNoStreaming.razor: Evaluated as low risk
- src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/EnhancedNav/PageForScrollingToHash.razor: Evaluated as low risk
- src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/EnhancedNav/PageForScrollingToHashNoStreaming.razor: Evaluated as low risk
Comments suppressed due to low confidence (1)
src/Components/Web.JS/src/Services/NavigationEnhancement.ts:98
- The function saveScrollPosition should handle cases where the state is null or undefined. Add a check to ensure the state is correctly handled.
const currentState = history.state || {};
src/Components/test/E2ETest/ServerRenderingTests/EnhancedNavigationTest.cs
Outdated
Show resolved
Hide resolved
…ationTest.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Running the tests locally on repeat revealed an issue with browser's navigation. When we use programmatic navigation, it does not always load the new page (the history state changes but the DOM stays the same, we can see it as failure to render the element of List of affected test cases: error: |
|
The test cases that fall into this path: are failing. This is not an issue connected with this PR and it happens on main as well. |
javiercn
left a comment
There was a problem hiding this comment.
Looks great!
Good job on the testing aspects of this feature, I know this is not a simple area and the coverage looks thorough!
…the history update.
Description
resetScrollAfterNextBatch()in enhanced navNavigateTodoes not scroll to the top in internal navigation to same url #60190 for client side navigation.WaitForElementToBeVisibleextension was added. Without it, the tests withenableStreaming=truewould not be deterministic.Fixes #51646