microsoft-ui-xaml icon indicating copy to clipboard operation
microsoft-ui-xaml copied to clipboard

Nested `ItemsView` Items stays highlighted on PointerOver

Open morning4coffe-dev opened this issue 11 months ago • 3 comments

Describe the bug

When nesting an ItemsView control inside another ItemsViews Item (or ItemsRepeater) the Items inside stay highlighted after hovering on them. This happens with all the new major versions and 1.7 experimental as well.

Steps to reproduce the bug

<ItemsRepeater ItemsSource="{x:Bind Categories, Mode=OneWay}">
    <ItemsRepeater.ItemTemplate>
        <DataTemplate x:DataType="local:Category">
            <ItemContainer>
                <StackPanel DataContext="{x:Bind}">

                    <TextBlock Text="{x:Bind Label}"
                               HorizontalAlignment="Center"
                               FontSize="20"
                               Margin="0,10,0,10" />

                    <ItemsView ItemsSource="{x:Bind}">
                        <ItemsView.ItemTemplate>
                            <DataTemplate x:DataType="local:Item">
                                <ItemContainer>
                                    <TextBlock Text="{x:Bind Label}"
                                               HorizontalAlignment="Center" />
                                </ItemContainer>
                            </DataTemplate>
                        </ItemsView.ItemTemplate>
                    </ItemsView>

                </StackPanel>
            </ItemContainer>
        </DataTemplate>
    </ItemsRepeater.ItemTemplate>
</ItemsRepeater>

NestedItemsViewHighlighting.zip

Expected behavior

No response

Screenshots

https://github.com/user-attachments/assets/2d207629-1ae1-4d33-98d3-0bec89863deb

NuGet package version

WinUI 3 - Windows App SDK 1.6.3: 1.6.241114003

Windows version

Windows Insider Build (xxxxx)

Additional context

Related to https://github.com/unoplatform/uno/issues/19180

morning4coffe-dev avatar Jan 23 '25 10:01 morning4coffe-dev

I did a little investigation with the source and the root cause seems to be happening in ItemsContainer ProcessPointerOver. When using a mouse the ResetIsMousePointerOver doesn't seem to be properly executed when the ItemsView is nested as the isPointerOver isn't changed during the method causing the UpdateVisualState call at the end to be skipped.

A potential hotfix would be to remove this check: https://github.com/microsoft/microsoft-ui-xaml/blob/ffe33f9b7d0e9f5a2ca3330d0ce329f09dff092b/src/controls/dev/ItemContainer/ItemContainer.cpp#L301 This change could resolve the issue, albeit with a minor performance impact.

morning4coffe-dev avatar Jan 24 '25 20:01 morning4coffe-dev

can you please take a loot at this https://github.com/microsoft/microsoft-ui-xaml/issues/10319 @joelleigh @mrlacey @MartyIX @morning4coffe-dev

manoj-sunagar avatar Jan 27 '25 06:01 manoj-sunagar

I also see the same or a similar issue with a normal (not nested) ItemsView when pressing the mouse button while hovering over an item and then moving the mouse outside the item's bounds before releasing the mouse button again

tipa avatar Jun 06 '25 13:06 tipa