Skip to content

[HR][Navigation] CascadeNewDefaultsFromRoot suppresses the refresh of the active route, so the displayed page is never re-instantiated #3142

Closed

Description

@kazo0

Current behavior

When a hot-reload delta updates a type that backs the currently displayed route, the page and its
view model are never re-instantiated, so the change is invisible until a full rebuild.

UpdateApplication runs, the route table rebuilds, ShouldCascadeForUpdatedTypes correctly decides the
change is navigation-relevant — and then CascadeNewDefaultsFromRoot suppresses the navigation because
the target region is already on that route. Nothing else forces a re-navigation.

This is most visible for edits that only affect a constructor or property initializer, because a
metadata update never re-runs constructors on live instances:

public ISeries[] DeploymentSeries { get; } = new ISeries[]
{
    new ColumnSeries<double> { Values = new double[] { 8, 14, 11, 22 } },  // hot-reload edit -> LineSeries<double>
};

That class of edit requires the page to be re-created to become visible. When the page is the active
route, it never is — so the effect is that the one page guaranteed not to refresh is the page the user
is looking at.

Expected behavior

If an updated type is the view or view model of a region's active route, that region should be
re-navigated (re-instantiated) rather than skipped.

How to reproduce

  1. App using Uno.Extensions.Navigation with a NavigationView shell and nested routes, e.g.

    views.Register(
        new ViewMap<MainPage, MainModel>(),
        new ViewMap<OverviewPage, OverviewModel>(),
        new ViewMap<PerformancePage, PerformanceModel>());
    
    routes.Register(
        new RouteMap("Main", View: views.FindByViewModel<MainModel>(),
            Nested:
            [
                new RouteMap("Overview", View: views.FindByView<OverviewPage>(), IsDefault: true),
                new RouteMap("Performance", View: views.FindByView<PerformancePage>()),
            ]));
  2. Run the app and stay on the default Overview page.

  3. Edit a property initializer on OverviewModel (a value that is only computed in the constructor).

  4. Apply hot reload.

  5. The UI does not change. The log shows the cascade being skipped.

Step 3 is the important part — a method-body edit or a XAML edit takes a different path and is not
affected.

Logs

info: Uno.Extensions.Navigation.Regions.NavigationRegion[0]
      UpdateApplication - Hot-reload UpdateApplication received 1 updated type(s); refreshing 1 navigation context(s)
info: Uno.Extensions.Navigation.MappedRouteResolver[0]
      LogResolverState - RouteResolver rebuilt: First='Main', TopLevelRoutes=2, TotalMappings=6
info: Uno.Extensions.Navigation.MappedRouteResolver[0]
      InternalDefaultMapping - For better performance (avoid reflection), create mapping for path 'OverviewModel', view 'OverviewModel', view model ''
warn: Uno.Extensions.Navigation.MappedRouteResolver[0]
      TypeFromPath - Navigation failed: Could not resolve type for path 'OverviewModel'.
dbug: Uno.Extensions.Navigation.MappedRouteResolver[0]
      InternalDefaultMapping - Created default mapping - Path 'OverviewModel'
dbug: Uno.Extensions.Navigation.Regions.NavigationRegion[0]
      ScheduleCascade - Scheduling cascade walk on dispatcher (root region: '', children: 1)
dbug: Uno.Extensions.Navigation.Regions.NavigationRegion[0]
      CascadeNewDefaultsFromRoot - Cascade skip on region '': IsDefault 'Overview' suppressed because descendant region 'Overview' already has active route 'Overview' (matches nested path of 'Main')

The TypeFromPath warning on line 4 is a red herring — InternalDefaultMapping recovers on the next
line ("Created default mapping"). It is noise, not the failure. (Separately: it would be nice for that
advisory not to log at warn when the fallback succeeds.)

The last line is the defect.

Root cause

In src/Uno.Extensions.Navigation.UI/NavigationRouteUpdateHandler.cs:

  • UpdateApplication(Type[] updatedTypes) → RebuildRoutes → ShouldCascadeForUpdatedTypes(updatedTypes, resolver)
    returns true when at least one updated type is registered as a view or view model. That check exists
    specifically to avoid re-mounting pages on XAML-only edits — so it has already concluded this edit
    should re-mount something.
  • ScheduleCascade → CascadeNewDefaultsFromRoot(IRegion region, RouteResolver resolver) calls
    FindActiveDescendantNestedRoute. When a descendant region's active route already matches one of the
    nested routes, the IsDefault cascade is skipped to preserve that selection.
  • RetryPendingFailedRequestsFromRoot only re-invokes RetryPendingFailedRequestAsync on navigators
    that hold a pending failed request. A region that navigated successfully at startup has none.
  • Net: there is no path that forces re-instantiation of a region whose active route corresponds to an
    updated type. Note that CascadeNewDefaultsFromRoot never receives updatedTypes at all.

The suppression itself is intentional and correct for the case it was added for — from
Given_HotReload.cs:

the fix ensures that walk respects RegionTwo's active selection and does NOT re-issue an IsDefault
navigation back to RegionOne

The problem is that two different situations share one branch:

Situation Correct action Today
Cascade wants a different default than the region's active route suppress — don't move the user suppress ✅
The active route's own view/view model was just updated re-navigate to re-instantiate it suppress ❌

Suggested fix

Thread updatedTypes through to the conflict check in CascadeNewDefaultsFromRoot, and when the
conflicting region's active route resolves to a view or view model in updatedTypes, force a
re-navigation of that same route instead of suppressing. ShouldCascadeForUpdatedTypes already performs
the "is this type registered as a view/view-model" lookup, so no new plumbing is needed — only the
condition changes.

Regression test: extend src/Uno.Extensions.Navigation.UI.Tests/Given_HotReload.cs to navigate to a
region, edit the active region's view model, and assert the page/view model is re-instantiated —
alongside the existing assertion that an unrelated IsDefault cascade does not yank the selection back.

Environment

Nuget Package (s): Uno.Extensions.Navigation, Uno.Extensions.Navigation.UI

Package Version(s): as shipped with Uno SDK 6.7.16

Affected platform(s):

  • WebAssembly
  • Windows
  • Skia (Desktop)

The affected code path is in Uno.Extensions.Navigation.UI and is not platform specific.

Code references are against main @ 3f5d79e4c4fad547bd651c4766f9d753d637330f.

Related

Activity

  1. added
    kind/bug
    on Aug 20, 2026
  2. self-assigned this
    on Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions