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.18k stars 373 forks source link

[BUG] ContentView hover does not restore BackgroundColor #1798

Open DennisWelu opened 4 months ago

DennisWelu commented 4 months ago

Is there an existing issue for this?

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

Current Behavior

Applying the TouchBehavior to a ContentView (at least on Windows) - when the hover state is complete the view retains the configured HoveredBackgroundColor and does not restore the original ContentView color. I've tried on a few controls, seems to be ContentView specific so far.

Expected Behavior

When the hover completes the original state of the view should be restored.

Steps To Reproduce

  1. Open and run the attached repro.
  2. Mouse over the image at the top.
  3. Mouse away from the image at the top. Notice the result is this red background color that does not go away: image
            <!-- Only change to the template empty project code is this ContentView with the TouchBehavior added around the Image -->
            <ContentView>
                <ContentView.Behaviors>
                    <toolkit:TouchBehavior
                        HoveredBackgroundColor="#88ff0000"/>
                </ContentView.Behaviors>
                <Image
                    Source="dotnet_bot.png"
                    HeightRequest="185"
                    Aspect="AspectFit"
                    SemanticProperties.Description="dot net bot in a race car number eight" />
            </ContentView>

Link to public reproduction project repository

https://github.com/DennisWelu/MctTouchBehaviorContentView

Environment

- .NET MAUI CommunityToolkit: 8.0.1
- OS: Windows 10 Pro 22H2
- .NET MAUI: 8.0.14

Anything else?

No response

MitchBomcanhao commented 4 months ago

As a workaround, you can set the DefaultBackgroundColor value so that it changes back to the expected value, eg DefaultBackgroundColor="Transparent"