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

IsEnabled doesn't update visual state after being updated with INotifyPropertyChanged when displaying shell alert on Windows 10 #8877

Closed
Laradius opened this issue Jul 21, 2022 · 13 comments · Fixed by #11840
Labels
area-controls-button Button, ImageButton fixed-in-7.0.59 Look for this fix in 7.0.59! fixed-in-7.0.100 fixed-in-7.0.101 fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/windows 🪟 t/bug Something isn't working

Comments

@Laradius
Copy link

Laradius commented Jul 21, 2022

Description

Visual state of button doesn't change after alert is displayed despite being enabled. It's visible as disable despite being clickable.

It works fine on Android.

image

ObservableProperty and ICommand is part of Microsoft.Toolkit.Mvvm.ComponentModel

        [ObservableProperty]
        [AlsoNotifyChangeFor(nameof(IsNotBusy))]
        private bool isBusy;
        public bool IsNotBusy => !IsBusy;
<Button Text="DisplayCommand" Command="{Binding DisplayAlertCommand}" IsEnabled="{Binding IsNotBusy}">
[ICommand]
public async Task DisplayAlertAsync()
        {
            IsBusy = true;
            bool answer = await Shell.Current.DisplayAlert("Question?", "Would you like to play a game", "Yes", "No");
            IsBusy = false;
        }

Steps to Reproduce

  1. Run app on Windows 10
  2. Click button
  3. Visual state doesn't update after alert is displayed.

Version with bug

6.0.419 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows 10

Did you find any workaround?

No response

Relevant log output

No response

@Laradius Laradius added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Jul 21, 2022
@Laradius Laradius changed the title IsEnabled doesn't update visual state after being updated with INotifyPropertyChanged when displaying shell alert IsEnabled doesn't update visual state after being updated with INotifyPropertyChanged when displaying shell alert on Windows 10 Jul 21, 2022
@Eilon Eilon added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Jul 21, 2022
@rmarinho rmarinho added s/needs-repro Attach a solution or code which reproduces the issue and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Jul 22, 2022
@ghost
Copy link

ghost commented Jul 22, 2022

Hi @Laradius. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@ghost ghost added the s/no-recent-activity Issue has had no recent activity label Jul 26, 2022
@ghost
Copy link

ghost commented Jul 26, 2022

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@ghost ghost removed the s/no-recent-activity Issue has had no recent activity label Jul 27, 2022
@Laradius
Copy link
Author

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels Jul 27, 2022
@Laradius
Copy link
Author

Laradius commented Aug 3, 2022

@Eilon @rmarinho Could I get informatiom regarding that issue?

@Eilon
Copy link
Member

Eilon commented Aug 4, 2022

@Laradius we will check this out in an upcoming bug triage meeting. I'm wondering if the async behavior is somehow affecting this? I'm not sure how the MVVM Toolkit attributes work with this, either. What happens if you call NotifyPropertyChanged(nameof(IsNotBusy)) after setting it to false?

@Laradius
Copy link
Author

Laradius commented Aug 5, 2022

@Laradius we will check this out in an upcoming bug triage meeting. I'm wondering if the async behavior is somehow affecting this? I'm not sure how the MVVM Toolkit attributes work with this, either. What happens if you call NotifyPropertyChanged(nameof(IsNotBusy)) after setting it to false?

Is not busy property returns true and notifies all bindings about the change.

@Ahmadmansoor
Copy link

Hi
I have already posted this at another repo
CommunityToolkit/dotnet#372
my problem is the button can't disable itself from the C# code.
and sometimes from the other buttons as well.
any guide pls, my whole work is stope at this stage.

@sude22
Copy link

sude22 commented Oct 5, 2022

Do anybody care about this issue?
Right now it is not possible to use Async Commands for buttons because the visual state of the button (from CanExecute) may be not correct after showing a DisplayAlert. A showstopper in the moment for MAUI on Windows.....

@hartez
Copy link
Contributor

hartez commented Nov 10, 2022

Possibly related: #9753

@mattleibow mattleibow added this to the Backlog milestone Nov 10, 2022
@ghost
Copy link

ghost commented Nov 10, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@mattleibow mattleibow added area-controls-button Button, ImageButton and removed s/needs-attention Issue has more information and needs another look labels Nov 10, 2022
@PureWeen
Copy link
Member

Possibly related CommunityToolkit/dotnet#316

@Sergio0694
Copy link

I've noticed the same in MAUI as well (it does indeed look related to #9753). This seems to be a MAUI specific issue and unrelated from the MVVM Toolkit per se (the same code works just fine on UWP and WinUI 3 too, for instance).

@Laradius unrelated, but you can simplify your code by removing those IsBusy/IsNotBusy properties entirely, and just bind to the IsRunning property exposed by the IAsyncRelayCommand property that the generator will create for you. For the inverted property (IsNotBusy), simply use a converter or x:Bind to function in XAML, you don't need an extra property 🙂

@mikeparker104 mikeparker104 added the partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with label Feb 2, 2023
@samhouts samhouts added p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint and removed p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint labels Feb 3, 2023
@samhouts samhouts added the p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint label Feb 3, 2023
@hartez
Copy link
Contributor

hartez commented Feb 4, 2023

This was fixed by #11840.

@hartez hartez closed this as completed Feb 4, 2023
@samhouts samhouts added p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint and removed p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint labels Feb 6, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Mar 8, 2023
@samhouts samhouts added fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! fixed-in-7.0.59 Look for this fix in 7.0.59! labels May 10, 2023
@samhouts samhouts modified the milestones: Backlog, .NET 7 + Servicing May 22, 2023
@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-button Button, ImageButton fixed-in-7.0.59 Look for this fix in 7.0.59! fixed-in-7.0.100 fixed-in-7.0.101 fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.