Skip to content

Commit

Permalink
🆕 feat(InputsFilter): expose the method for notifying field updates (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem authored Jul 12, 2024
1 parent 015a31f commit a1ac3d5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
7 changes: 1 addition & 6 deletions src/Masa.Blazor/Components/Input/MInput.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,7 @@ protected async Task TryInvokeFieldChangeOfInputsFilter(bool isClear = false)
return;
}

if (!ValueIdentifier.HasValue)
{
throw new InvalidOperationException("If you split the @bind-Value into Value and ValueChanged, the ValueExpression is required.");
}

await InputsFilter.FieldChange(ValueIdentifier.Value.FieldName, isClear);
await InputsFilter.NotifyFieldChange(ValueIdentifier?.FieldName, isClear);
}

public void ResetFilter()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
namespace Masa.Blazor;

public class InputsFilterFieldChangedEventArgs : EventArgs
public class InputsFilterFieldChangedEventArgs(string? fieldName, bool isClear) : EventArgs
{
public InputsFilterFieldChangedEventArgs(string fieldName, bool isClear)
{
FieldName = fieldName;
IsClear = isClear;
}
public string? FieldName { get; } = fieldName;

public string FieldName { get; }

public bool IsClear { get; }
public bool IsClear { get; } = isClear;
}
4 changes: 2 additions & 2 deletions src/Masa.Blazor/Components/InputsFilter/MInputsFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
builder.AddAttribute(3, nameof(ChildContent), ChildContent);
builder.CloseComponent();
}

internal Task FieldChange(string fieldName, bool isClear = false)
public Task NotifyFieldChange(string? fieldName, bool isClear = false)
=> OnFieldChanged.InvokeAsync(new InputsFilterFieldChangedEventArgs(fieldName, isClear));

internal void RegisterInput(IFilterInput input)
Expand Down

0 comments on commit a1ac3d5

Please sign in to comment.