ant-design-blazor/components/descriptions/DescriptionsItem.razor.cs
LI ZICHAO 71bac2e85d fix: children components dispose (#399)
* Children components using CascadingParameter add itself to parent component.However, when children components disposed, they are not remove from parent component. For example, when items in checkgroup have changed , it may causes Index was outside the bounds of the array at AntDesign.CheckboxGroup.OnCheckboxChange.To fix these bug, Adding remove function in dispose process is the solution of this commit.

* fix: some exception

Co-authored-by: ElderJames <shunjiey@hotmail.com>
2020-07-21 23:48:43 +08:00

37 lines
906 B
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using OneOf;
namespace AntDesign
{
public partial class DescriptionsItem : AntDomComponentBase, IDescriptionsItem
{
[Parameter]
public OneOf<string, RenderFragment> Title { get; set; } = "";
[Parameter]
public int Span { get; set; } = 1;
[Parameter]
public RenderFragment ChildContent { get; set; }
[CascadingParameter]
public Descriptions Descriptions { get; set; }
protected override void Dispose(bool disposing)
{
this.Descriptions?.Items.Remove(this);
base.Dispose(disposing);
}
protected override void OnInitialized()
{
this.Descriptions?.Items.Add(this);
base.OnInitialized();
}
}
}