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
57 changes: 0 additions & 57 deletions src/LumexUI/Components/Select/Core/_ItemsCollectedNotifier.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) LumexUI 2024
// LumexUI licenses this file to you under the MIT license
// See the license here https://github.com/LumexUI/lumexui/blob/main/LICENSE

using System.ComponentModel;

using Microsoft.AspNetCore.Components;

using IComponent = Microsoft.AspNetCore.Components.IComponent;

namespace LumexUI.Internal;

/// <summary>
/// For internal use only.
/// </summary>
[EditorBrowsable( EditorBrowsableState.Never )]
public sealed class ItemsCollectedNotifier<TValue> : IComponent
{
[CascadingParameter] private SelectContext<TValue> Context { get; set; } = default!;

private LumexSelect<TValue> Select => Context.Owner;

private bool _isFirstRender = true;

void IComponent.Attach( RenderHandle renderHandle )
{
// This component never renders, so we can ignore the renderHandle
}

Task IComponent.SetParametersAsync( ParameterView parameters )
{
if( _isFirstRender )
{
parameters.SetParameterProperties( this );

if( Context.IsMultipleSelect )
{
Context.UpdateSelectedItems( Select.Values );
}
else
{
Context.UpdateSelectedItem( Select.Value );
}

_isFirstRender = false;
return Task.CompletedTask;
}
else
{
return Task.CompletedTask;
}
}
}
4 changes: 2 additions & 2 deletions src/LumexUI/Components/Select/LumexSelect.razor
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@{
_context.FinishCollectingItems();
}
<_ItemsCollectedNotifier TValue="TValue" />
<ItemsCollectedNotifier TValue="TValue" />

<div class="@_slots.Base"
style="@RootStyle"
Expand Down Expand Up @@ -95,7 +95,7 @@
@ref="@_popoverRef"
@bind-Open="@_isOpen">
<LumexPopoverContent>
@if( _context.IsMultiSelect )
@if( _context.IsMultipleSelect )
{
<LumexListbox TValue="TValue"
Values="@CurrentValues"
Expand Down
Loading
Loading