Skip to content

InMemoryNavigationProvider<T> drops a legitimately-null current destination from history #31

Description

@matt-edmondson

What's wrong

InMemoryNavigationProvider<T>.NavigateTo, GoBack, and GoForward (Essentials.NavigationProviders.InMemory/InMemoryNavigationProvider.cs:49-51, 70-72, 93-95) guard pushing the current destination onto the back/forward stack with if (Current is not null). For INavigationProvider<string> or any other nullable T where null is a legitimate navigation destination (e.g. a "no selection" state), this conflates "no current destination has been set yet" with "the current destination happens to be null", and silently drops that step from history.

Failure scenario

provider.NavigateTo("a");
provider.NavigateTo(null);   // legitimate destination, pushes "a" fine
provider.NavigateTo("b");    // Current is null here, so the null step is never pushed
provider.GoBack();           // returns "a" directly, skipping the null entry entirely

The null-destination step vanishes from history instead of being the immediate previous page.

Suggested fix

Track "has a current destination been set" with an explicit bool hasCurrent flag (or a nullable-aware sentinel) instead of testing Current is not null, so a legitimately-null Current is still pushed onto the stacks.

Acceptance criteria

A test using InMemoryNavigationProvider<string?> (or similar) that navigates through a null destination and calls GoBack/GoForward observes the null step in history rather than skipping it.

No activity

Activity on this issue will appear here.

Activity

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

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions