CommunityToolkit / Maui

The .NET MAUI Community Toolkit is a community-created library that contains .NET MAUI Extensions, Advanced UI/UX Controls, and Behaviors to help make your life as a .NET MAUI developer easier
https://learn.microsoft.com/dotnet/communitytoolkit/maui
MIT License
2.25k stars 390 forks source link

[BUG] TintColorBehavior does not work correctly within a popup control #2137

Open CraigBelser opened 2 months ago

CraigBelser commented 2 months ago

Is there an existing issue for this?

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

The IconTintColorBehavior when used in a community in toolkit popup on the windows platform loses the tint color when the popup is reopened. The color will initially show up on the first use, but subsequent uses lose the tint color. Beyond the community toolkit popup that is part of the code repro, it also happens in custom dropdowns for other controls like the Telerik combo box dropdown and other third party dropdowns.

https://github.com/user-attachments/assets/501031b4-c3b9-4360-966b-ce5c9d27eb80

Expected Behavior

Tint color will remain on the target control when the popup reopens.

Steps To Reproduce

  1. Open and run the attached repro
  2. press the popup button
  3. see the tint
  4. close the popup using the close button on the popup
  5. reopen the popup
  6. see the tint color loss

Link to public reproduction project repository

https://github.com/ImpySoft/TintColorIssue

Environment

- .NET MAUI CommunityToolkit: 9.0.3
- OS: Windows
- .NET MAUI: 8

Anything else?

No response

cat0363 commented 2 months ago

@CraigBelser , Popup is not designed to reuse instances. After modifying it as below, it should work as intended.

    public partial class MainPage : ContentPage
    {
        private TestPopup testPopup; 

       public MainPage()
        {
            InitializeComponent();
        }

        private void OnPopupButtonClicked(object? sender, EventArgs e)
        {
            //part of this test is reusing the popup to maintain state.  Creating a new one would bypass the issue.
            testPopup = new TestPopup();            
            this.ShowPopup(testPopup);
        }
    }

FYI. https://github.com/CommunityToolkit/Maui/issues/1377

CraigBelser commented 2 months ago

@cat0363 My apologies for missing that reference. However; beyond the community toolkit popup example that is part of the code repro, it also happens in custom dropdowns for other controls like the Telerik combo box dropdown and other third party dropdowns. This issue is for most other popups across windows. I will update the repro to show a couple of additional examples.