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

[Bug] Alerts currently don't work if you call them from the constructor #1514

Closed
PureWeen opened this issue Jul 1, 2021 · 10 comments
Closed
Labels
area-controls-dialogalert DisplayAlert, dialog s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@PureWeen
Copy link
Member

PureWeen commented Jul 1, 2021

Description

If you call DisplayAlert from the constructor of a page it currently does not work on WinUI

Go to the alerts page and add a call to DisplayAlert from the ctor

public AlertsPage()
{
      DisplayFromCtor();
}

async void DisplayFromCtor() =>  await DisplayAlert();
@jsuarezruiz jsuarezruiz added the t/bug Something isn't working label Oct 25, 2021
@hartez hartez added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Nov 5, 2021
@hartez
Copy link
Contributor

hartez commented Nov 5, 2021

In Forms calling alerts from the constructor would put them in a queue that would be processed after Appearing; maybe the queue stuff didn't get ported?

@Eilon
Copy link
Member

Eilon commented Feb 11, 2022

There's a dup here suggesting maybe we shouldn't support it: #4336

@jamesmontemagno
Copy link
Member

IMHO this should not be a supported scenario that could be documented. The UI isn't visible yet, you basically shouldn't do anything in your constructor.

@Eilon
Copy link
Member

Eilon commented Feb 11, 2022

I'm guessing people do it because it's the logical equivalent of printf debugging. No strong opinion on whether it should be allowed.

@PureWeen
Copy link
Member Author

PureWeen commented Feb 11, 2022

Another use case here is that the ctor is the easiest place for an alert you only want to show on the first load of a page. In theory you could check for this case in "Appearing" but it's a bit more code and since the ctor works then why not just put it there.

@jamesmontemagno
Copy link
Member

We could introduce a "FirstLoad" type of thing like blazor... so you ahve OnAPpearing that happens eveyr time, but OnFirstLoad or something that is after the screen loads for teh first time?

@shimingsg
Copy link

Not reproducible with Android 11.

@shimingsg shimingsg added the s/verified Verified / Reproducible Issue ready for Engineering Triage label Feb 17, 2022
@Eilon
Copy link
Member

Eilon commented Feb 18, 2022

Re-opening because I'm not sure if this is the right behavior on all platforms, even if perhaps it works on Android.

@Eilon Eilon reopened this Feb 18, 2022
@Eilon
Copy link
Member

Eilon commented Feb 18, 2022

The dup bug specifically mentioned that it doesn't work on Windows: #4336

@Redth Redth modified the milestones: 6.0.300, 6.0.300-servicing Mar 22, 2022
@jsuarezruiz
Copy link
Contributor

Testing with RC3 and main branch, this is now working:
image

Reviewing the history have been fixed by the commit fffaae1.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 11, 2022
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-dialogalert DisplayAlert, dialog s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants