@if (IsVisible) { } @code { [Parameter] public bool IsVisible { get; set; } [Parameter] public EventCallback IsVisibleChanged { get; set; } [Parameter] public int AreaId { get; set; } [Parameter] public string AreaName { get; set; } = string.Empty; [Parameter] public int? CurrentParentId { get; set; } [Parameter] public IEnumerable<(int? Id, string Label)> ParentOptions { get; set; } = Array.Empty<(int?, string)>(); [Parameter] public string? ErrorMessage { get; set; } [Parameter] public EventCallback<(int AreaId, int? NewParentId)> OnSubmit { get; set; } private bool _wasVisible; private int? _targetParentId; protected override void OnParametersSet() { if (IsVisible && !_wasVisible) { _targetParentId = CurrentParentId; } _wasVisible = IsVisible; } private async Task Close() => await IsVisibleChanged.InvokeAsync(false); private async Task Submit() => await OnSubmit.InvokeAsync((AreaId, _targetParentId)); }