Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation using Region Crazy bug #2605

Open
2 tasks
KWodarczyk opened this issue Nov 7, 2024 · 0 comments
Open
2 tasks

Navigation using Region Crazy bug #2605

KWodarczyk opened this issue Nov 7, 2024 · 0 comments
Labels
kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification.

Comments

@KWodarczyk
Copy link

KWodarczyk commented Nov 7, 2024

Current behavior

When Region value is a substring of Page name, browser refresh will skip main page.
ヽ(ຈل͜ຈ)ノ︵ ┻━┻

Working fine after refresh

image

Not working if Region value same as Page name

image

image

<Page x:Class="UnoAppNavigation2.Presentation.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="using:UnoAppNavigation2"
      xmlns:Presentation="using:UnoAppNavigation2.Presentation"
      xmlns:uen="using:Uno.Extensions.Navigation.UI"
      xmlns:utu="using:Uno.Toolkit.UI"
      Loaded="Page_Loaded"
      Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  <Page.Resources>
    <x:String x:Key="PageOne">aFirstPage</x:String><!--magic: change it to aFirstPage or FirstPagea and it will work--> 
    <x:String x:Key="PageTwo">PageTwo</x:String>
  </Page.Resources>

  <Grid uen:Region.Attached="True" RowDefinitions="auto,*">
    <StackPanel Grid.Row="0" HorizontalAlignment="Left" Orientation="Horizontal" Background="DarkSlateGray">
         <TextBlock>
           <Run Text="URL:"/>
           <Run x:Name="UrlPath"/>
         </TextBlock>
    </StackPanel>

        <NavigationView Grid.Row="1"
            uen:Region.Attached="true"
            PaneDisplayMode="Top"
            IsSettingsVisible="False"
            ItemInvoked="NavigationView_ItemInvoked"
            IsBackButtonVisible="Collapsed"
            IsBackEnabled="False">
            <NavigationView.MenuItems>

                <NavigationViewItem
                  Content="One"
                  x:Name="OneTab"
                  IsSelected="True"
                  uen:Region.Name="{StaticResource PageOne}" />

                <NavigationViewItem
                  Content="Two"
                  x:Name="TwoTab"
                  uen:Region.Name="{StaticResource PageTwo}" />


            </NavigationView.MenuItems>

            <Grid uen:Region.Attached="True"
                  uen:Region.Navigator="Visibility">

              <Presentation:FirstPage Visibility="Collapsed" uen:Region.Name="{StaticResource PageOne}"/>
              <Presentation:SecondPage Visibility="Collapsed" uen:Region.Name="{StaticResource PageTwo}"/>

            </Grid>
        </NavigationView>
    </Grid>
</Page>
public sealed partial class MainPage : Page
{
    private App? _app;

    public MainViewModel? ViewModel { get; set; }

    public MainPage()
    {
        _app = (Application.Current as App);

        INavigator navigator = this.Navigator();

        this.InitializeComponent();

        UrlPath.Text =  _app?.MainHref + " base url:"+_app.BaseUrl;
    }

    private void NavigationView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
    {
        Console.WriteLine($"==== Navigation invoked =====");
    }

    private async void Page_Loaded(object sender, RoutedEventArgs e)
    {
        var navigator = this.Navigator();

        Console.WriteLine($"==== Main Page Loaded href = {_app.MainHref} =====");


        if(_app?.MainHref is not null)
        {
            Console.WriteLine($"====    Navigation to {_app.MainHref} =======");
            var result = await navigator.NavigateRouteAsync(this, _app.MainHref);
        }
    }
}

Expected behavior

ummm it just should work regardless of what value the Region has ?

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

  1. Just build and rung the code submitted
  2. Refresh browser
  3. Main page is gone (Bug)
  4. Now add any thing before or after FirstPage e.g change <x:String x:Key="PageOne">aFirstPage</x:String>
  5. Repeat test again and it will work.

Environment

Nuget Package (s):

Package Version(s):

Affected platform(s):

  • WebAssembly

Visual Studio:

  • 2022 (version: )

Relevant plugins:

UnoAppNavigation2.zip

Anything else we need to know?

@KWodarczyk KWodarczyk added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification. labels Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification.
Projects
None yet
Development

No branches or pull requests

1 participant