microsoft / fluentui-blazor

Microsoft Fluent UI Blazor components library. For use with ASP.NET Core Blazor applications
https://www.fluentui-blazor.net
MIT License
3.84k stars 372 forks source link

fix: [TreeView] @bind-SelectedItem does not work when clicking on an icon. #2659

Closed k111s222 closed 1 month ago

k111s222 commented 1 month ago

πŸ› Bug Report

πŸ’» Repro or Code Sample

https://www.fluentui-blazor.net/TreeView 'With Items'

As can be seen in the "With Items" example on the fluentui-blazor.net page, when clicking on an icon or a number enclosed in square brackets, the selected item (@bind-SelectedItem="@SelectedItem") is not work.

πŸ€” Expected Behavior

I expected the bind-SelectedItem to change when clicking the icon or text (generated from the ItemTemplate) of a list item.

😯 Current Behavior

πŸ’ Possible Solution

The solution I implemented to resolve this issue was to create an empty div that overlays the list item and apply the onclick event to that div. <div @onclick="async(e) => await HandleSelect(myTreeViewItem)" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(256,0,0,0.1); z-index: 10;"></div>

πŸ”¦ Context

🌍 Your Environment

dvoituron commented 1 month ago

The problem seems linked to the WebComponents: when an element contains HTML tags (and not just text), the content seems unselectable. I don't think I'll be able to find a solution/hack immediately via our Blazor library, without having the web components corrected. We'll try to find a way.

In this example, the second item contains a "formatted" element using <div> and this item is no longer selectable.

<fluent-tree-view>
  <fluent-tree-item>One</fluent-tree-item>
  <fluent-tree-item><div>Two</div></fluent-tree-item>
  <fluent-tree-item>Three</fluent-tree-item>
</fluent-tree-view>
vnbaaij commented 1 month ago

Closing this as it is not actionable from our side. The v2 web components will not see updates anymore...