unoplatform / uno.extensions

Libraries to ease common developer tasks associated with building multi-platform mobile, desktop and web applications using Uno Platform or WinAppSDK.
https://platform.uno/
Other
73 stars 45 forks source link

App Layout Blanks Out When Navigating to Invalid Route #2382

Closed Kunal22shah closed 2 weeks ago

Kunal22shah commented 2 months ago

Current behavior

When navigating to a route that matches a common type name with suffixes (e.g., List, resulting in ListView), the app goes blank and logs a warning: Uno.Extensions.Navigation.Navigators.ContentControlNavigator: Warning: CreateControlFromType - Type not registered ListView, so calling Activator.

Expected behavior

Navigating to a route that is not registered should handle the error and avoid causing the app to go blank/crash.

How to reproduce it (as minimally and precisely as possible)

  1. Create a new Uno App.
  2. Set up a navigation button with an invalid path using uen:Navigation.Request (e.g., List).
  3. Observe that navigating to this invalid path causes the app layout to go blank. Minimal Repro Project: NavigationBug.zip

Environment

Nuget Package (s):

Package Version(s):

Affected platform(s):

Visual Studio:

Relevant plugins:

Anything else we need to know?

Original Issue : https://github.com/unoplatform/uno/issues/17238

The issue seems to stem from the type resolution logic in RouteResolverDefault: https://github.com/unoplatform/uno.extensions/blob/main/src/Uno.Extensions.Navigation.UI/RouteResolverDefault.cs#L149-L173 https://github.com/unoplatform/uno.extensions/blob/848ac33909af8b4f5c14fd42ed3f7424f23350ed/src/Uno.Extensions.Navigation.UI/RouteResolverDefault.cs#L9

agneszitte commented 1 month ago

@nickrandolph, @eriklimakc, @kazo0 please sync with @francoistanguay if further discussions are needed regarding reserved route names to determine the expected fix for this issue please. (Initial discussion here).

The fix may involve for example:

kazo0 commented 4 weeks ago

There has been documentation added surrounding this scenario as part of https://github.com/unoplatform/uno.extensions/pull/2317

See: https://github.com/unoplatform/uno.extensions/blob/main/doc/Learn/Navigation/HowTo-DefineRoutes.md#routemap

@eriklimakc / @vatsashah45 We should continue to investigate this and at least avoid the app crashing/going blank when a route like this is used. Perhaps just ignore the navigation and log a warning/error

fyi @agneszitte / @nickrandolph