Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Shell query parameter not being set before OnAppearing of page is called #11549

Open
tsequeira-vhs opened this issue Jul 24, 2020 · 13 comments
Labels

Comments

@tsequeira-vhs
Copy link

Description

Shell page parameter navigation does not set parameter for page before OnAppearing is called. In prior releases, the OnAppearing used to be called after the paramters were set allowing us to load the content based on the parameter.

Steps to Reproduce

  1. Use Shell page and add 2 pages
  2. Navigate from page 1 to page 2 using GoToAsync("Page2?id=5");
  3. Observe that OnAppearing of page 2 is called before the id parameter is set

Expected Behavior

The parameter set should be called before the OnAppearing is called

Actual Behavior

OnAppearing of page 2 is called before the id parameter is set

Basic Information

  • Version with issue: Xamarin.Forms 4.7.0.1080
  • Last known good version: Xamarin.Forms 4.6.x and versions below
@tsequeira-vhs tsequeira-vhs added s/unverified New report that has yet to be verified t/bug 🐛 labels Jul 24, 2020
@tsequeira-vhs tsequeira-vhs changed the title [Bug] [Bug] Shell query parameter not being set before OnAppearing of page is called Jul 24, 2020
@PureWeen PureWeen added the 4.6.0 regression on 4.6.0 label Aug 5, 2020
@PureWeen PureWeen self-assigned this Aug 5, 2020
@PureWeen PureWeen removed the s/unverified New report that has yet to be verified label Aug 5, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@tsequeira-vhs
Copy link
Author

Will this issue be fixed in 5.0.0?

@elcainas
Copy link

I tested in Xamarin.Forms 4.6.x , 4.8.x same issue

@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@tsequeira-vhs
Copy link
Author

@samhouts Does this mean that this issue will no longer be fixed?

@attilavlacsil
Copy link

With 4.8.0.1687 I have the same issue, but the actual behavior happens only if I navigate to the page for the first time, any subsequent navigation works as expected.

If I have a similar page to track constructor, query property and OnAppearing call order

[QueryProperty(nameof(QueryData), nameof(QueryData))]
public partial class ShellPage : ContentPage
{
    private readonly ShellPageViewModel viewModel;

    public string QueryData
    {
        set
        {
            Trace.WriteLine("ShellPage.QueryData setter");

            viewModel.QueryData = value;
        }
    }

    public ShellPage()
    {
        Trace.WriteLine("ShellPage ctor");

        InitializeComponent();
        BindingContext = viewModel = new ShellPageViewModel();
    }

    protected override void OnAppearing()
    {
        Trace.WriteLine("ShellPage.OnAppearing");

        base.OnAppearing();
    }
}

Navigating to the page for the first time outputs

[0:] ShellPage ctor
[0:] ShellPage.OnAppearing
[0:] ShellPage.QueryData setter

Any subsequent navigation outputs

[0:] ShellPage.QueryData setter
[0:] ShellPage.OnAppearing

As mentioned, the order must be consistent for any given navigation.

@archergod
Copy link

I am having same Issue with 5.0.0.2012

@andrybany
Copy link

I have also had this problem for some time.
A little while ago I just discovered that it can be remedied like this:

protected async override void OnAppearing()
{
    base.OnAppearing();
    await Task.Yield();
    //DO some stuff with QueryProperty populated 
}

@PureWeen PureWeen removed their assignment Aug 3, 2022
@ahmadk611
Copy link

I am having same problem 5.0.0.2478

@janseris
Copy link

@PureWeen Hello? This is still a problem in MAUI 7.0.81. It works (ApplyQueryAttributes called before OnAppearing) either only first time or never (it's not determistic).

@Scott-McEachern-SRT
Copy link

Still an issue with MAUI. The first time the page loads the query properties are not populated when the OnAppearing is fired.

@PureWeen
Copy link
Contributor

Still an issue with MAUI. The first time the page loads the query properties are not populated when the OnAppearing is fired.

Is there an issue on the MAUI repository for this?

@plppp2001
Copy link

Yes, I just noticed this happens sometimes for me 30% of the time OnAppearing gets called before ApplyQueryAttributes.

@janseris
Copy link

Still an issue with MAUI. The first time the page loads the query properties are not populated when the OnAppearing is fired.

Is there an issue on the MAUI repository for this?

Should it be so that it is solved? Shell is for both MAUI and Xamarin or does it differ?

@plppp2001
Copy link

Is there Maui bug for this out there?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests