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.23k stars 294 forks source link

fix: _tabs clear in fluent tabs #1959

Closed day-draze closed 2 weeks ago

day-draze commented 3 weeks ago

πŸ› Bug Report

The moment we try to load in data dynamic to the fluent tabs (in our case we load data on a navigation click, and on another navigation click we fill it with other data, and then when we press on the first navigation button again) it starts complaining about duplicate keys in the _tabs array.

πŸ’» Repro or Code Sample

@foreach (var item in Items) { Content #@item.Index - @item.Name }

@code { put some data, then some other data, and then the first data again on a component that calls this [Parameter] List Items = new List(); }

πŸ€” Expected Behavior

It should just display the items it has in the list. So basically clear the list.

😯 Current Behavior

Allows changes to other items, but once you start loading in data you already had in there at some previous point, it complains that _tabs already contains this key

πŸ’ Possible Solution

There are two routes, either there gets made a fix that on a set of the list, there gets checked which items have left the array, based on the ID. or you give us the option to manually clear the array:

///

/// Clear the tabs array /// public async Task ClearTabs() { _tabs.Clear(); }

πŸ”¦ Context

This issue has affected me in the sense that i looked annoyed at my screen way to long, but in all seriousness, we need to have tracking of what is actually still in the tabs array, and not keep track of items that are not there anymore on a c#/blazor level.

🌍 Your Environment

Ran on a beautiful Windows 11 Lenovo thinkpad, .net 8.

vnbaaij commented 2 weeks ago

The code you provided is not a reproduction we can use and does not demonstrate the issue. I need to be able to copy, paste and run. Besides, I dont understand from your description what you are trying to accomplish. Please make it more clear what you want to do. We can not just clear the list because we can't 'transport' that to the underlying web component.

vnbaaij commented 2 weeks ago

No repro provided