Skip to content

Don't restore page state on first load#8635

Closed
adamint wants to merge 5 commits intomicrosoft:mainfrom
adamint:dev/adamint/dont-restore-page-state-on-first-load
Closed

Don't restore page state on first load#8635
adamint wants to merge 5 commits intomicrosoft:mainfrom
adamint:dev/adamint/dont-restore-page-state-on-first-load

Conversation

@adamint
Copy link
Copy Markdown
Member

@adamint adamint commented Apr 8, 2025

Description

I noticed that there's a bug with the current "state restore" logic. If you navigate intentionally to a different url (ie by updating the url in the omnibar and navigating), the existing page state will still be restored.

This disables state restore just for the initial page load. The main purpose of this state restoration logic is to restore state when navigating between pages, which isn't touched.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

tests/Aspire.Dashboard.Components.Tests/Shared/TestSessionStorage.cs:34

  • The DeleteAsync method is implemented as a no-op stub. Consider adding test cases to verify deletion behavior to ensure consistency with production implementations.
public Task DeleteAsync(string key)

tests/Aspire.Dashboard.Components.Tests/Shared/TestLocalStorage.cs:42

  • The new DeleteAsync stub here would benefit from tests that confirm its intended use, especially given its role in state management.
public Task DeleteAsync(string key)


protected override async Task OnInitializedAsync()
{
NavigationManager.LocationChanged += (_, _) => NavigationService.IsFirstPageLoad = false;
Copy link

Copilot AI Apr 8, 2025

Choose a reason for hiding this comment

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

Consider unsubscribing from the NavigationManager.LocationChanged event in the component's Dispose method to prevent potential memory leaks.

Copilot uses AI. Check for mistakes.
@JamesNK
Copy link
Copy Markdown
Member

JamesNK commented Apr 10, 2025

I couldn't understand the problem from your description. Could you add a recording of the problem?

@adamint
Copy link
Copy Markdown
Member Author

adamint commented Apr 14, 2025

I noticed that this only happens when a following slash is not added to the url (ie, repros with /structuredlogs but not with /structuredlogs/). I think this solution is too complicated for the benefit we'd get, so closing.

@adamint adamint closed this Apr 14, 2025
@github-actions github-actions bot locked and limited conversation to collaborators May 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants