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

OnAppearing of Page called again, although this page was on already replaced NavigationStack #25089

Open
messemaSICKAG opened this issue Oct 4, 2024 · 3 comments · May be fixed by #25596
Open
Labels
p/2 Work that is important, but is currently not scheduled for release platform/android 🤖 platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@messemaSICKAG
Copy link

Description

Starting from MainPage(1), when clicking a button I put a page on navigation stack.
OnAppearing of this page(2) triggers an process in my app (in bug-repo it shows a display alert).
Clicking the button on the page replaces the navigation stack by another page (3).
Clicking the button on this page navigates to MainPage(1), but calling the OnAppearing-Event of the page(2).

Steps to Reproduce

Checkout + Build Repo
Click on the button on each view to perform the navigation that produces the issue
A display alert is shown when "Select Device Page" is shown (the first time its okay)
After showing MainPage again the display alert is shown again (which it should not).

Link to public reproduction project repository

https://github.com/messemaSICKAG/BugRepoOnAppearingCall

Version with bug

8.0.91 SR9.1

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

@guyvaio
Copy link

guyvaio commented Oct 5, 2024

There is no bug at this place. The page is appearing, so OnAppearing is raised.
If you want the behavior you describe, replace your code by:

private bool firstAppearing = true;

private void SelectDevicePage_OnAppearing(object? sender, EventArgs e)
{
    if (firstAppearing)
    {
        DisplayAlert("SelectDevicePage", "... appeared", "Ok");
        firstAppearing = false;
    }
}

@messemaSICKAG
Copy link
Author

Okay, I updated the repo to make the point more clear. Of course the view should appear, but only once. The problem is that 'OnAppearing' is called again when the App shows a complete different page (in this case the MainPage again).

Startup
--> MainPage shown
--> SelectDevicePage On NavigationStack (OnAppearing called the first time)
--> DeviceSpecificPage - NavigationStack replaced
--> MainPage - NavigationStack replaced (OnAppearing of SelectDevicePage called the second time)

private int _appearingCount;

private void SelectDevicePage_OnAppearing(object? sender, EventArgs e)
{
    if(_appearingCount > 0)
    {
        DisplayAlert("SelectDevicePage", "... appeared more than once", "Ok");
    }
    _appearingCount++;
}

@jaosnz-rep jaosnz-rep added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Oct 9, 2024
@jaosnz-rep
Copy link

I can repro this issue at Android platform on the latest 17.12.0 Preview 2.1(8.0.90 & 8.0.91).

@PureWeen PureWeen added this to the Backlog milestone Oct 23, 2024
@PureWeen PureWeen added the p/2 Work that is important, but is currently not scheduled for release label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p/2 Work that is important, but is currently not scheduled for release platform/android 🤖 platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
5 participants