Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5561,6 +5561,12 @@
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentOverflowItem.SetProperties(System.Nullable{System.Boolean},System.String)">
<summary />
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentOverflowItem.Dispose">
<summary />
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentOverflowItem.Dispose(System.Boolean)">
<summary />
</member>
<member name="T:Microsoft.FluentUI.AspNetCore.Components.OverflowItem">
<summary />
</member>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
</FluentOverflow>

<FluentButton @onclick="@AddNewItemClick">Add</FluentButton>
<FluentButton @onclick="@RemoveFirstItemClick">Remove</FluentButton>

@code
{
Expand All @@ -33,12 +34,17 @@
void OverflowHandler(IEnumerable<FluentOverflowItem> items)
{
var text = String.Join("; ", items.Select(i => i.Text));

}

void AddNewItemClick()
{
var index = new Random().NextInt64(Catalog.Length);
Items.Add(Catalog[index]);
}

void RemoveFirstItemClick()
{
Items.RemoveAt(0);
}
}
6 changes: 6 additions & 0 deletions src/Core/Components/Overflow/FluentOverflow.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ internal void AddItem(FluentOverflowItem item)
_items.Add(item);
}

internal void RemoveItem(FluentOverflowItem item)
{
_items.Remove(item);
StateHasChanged();
}

/// <inheritdoc />
public async ValueTask DisposeAsync()
{
Expand Down
32 changes: 31 additions & 1 deletion src/Core/Components/Overflow/FluentOverflowItem.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
namespace Microsoft.FluentUI.AspNetCore.Components;

/// <summary />
public partial class FluentOverflowItem
public partial class FluentOverflowItem : IDisposable
{
private bool _disposed;

/// <summary />
protected string? ClassValue => new CssBuilder(Class)
.AddClass("power-overflow-item")
Expand Down Expand Up @@ -58,4 +60,32 @@ internal void SetProperties(bool? isOverflow, string? text)
Overflow = isOverflow == true ? isOverflow : null;
Text = text ?? string.Empty;
}

/// <summary />
public void Dispose()
{
Dispose(false);
}

/// <summary />
protected virtual void Dispose(bool disposing)
{
if (_disposed) return;

try
{
// Release unmanaged resources (natives).
// ...

if (disposing) return;

// Dispose managed resources.
Container.RemoveItem(this);
}
finally
{
_disposed = true;
if (!disposing) GC.SuppressFinalize(this);
}
}
}