Skip to content

Commit

Permalink
feat(blazorui): use CallOnSet attribute for Culture parameter in BitT…
Browse files Browse the repository at this point in the history
…imePicker #8407 (#8413)
  • Loading branch information
Cyrus-Sushiant authored Aug 26, 2024
1 parent 435b7dd commit 3206829
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ private string? _minuteView
/// CultureInfo for the TimePicker
/// </summary>
[Parameter, ResetClassBuilder]
[CallOnSet(nameof(HandleParameterChanges))]
public CultureInfo? Culture { get; set; }

/// <summary>
Expand Down Expand Up @@ -309,11 +310,6 @@ protected override void OnInitialized()
base.OnInitialized();
}

protected override void OnParametersSet()
{
_culture = Culture ?? CultureInfo.CurrentUICulture;
}

protected override bool TryParseValueFromString(string? value, [MaybeNullWhen(false)] out TimeSpan? result, [NotNullWhen(false)] out string? validationErrorMessage)
{
if (value.HasNoValue())
Expand Down Expand Up @@ -432,6 +428,11 @@ private async Task HandleOnClick()
await OnClick.InvokeAsync();
}

private void HandleParameterChanges()
{
_culture = Culture ?? CultureInfo.CurrentUICulture;
}

private async Task UpdateCurrentValue()
{
CurrentValue = (_hour.HasValue is false || _minute.HasValue is false) ? null : new TimeSpan(_hour.Value, _minute.Value, 0);
Expand Down

0 comments on commit 3206829

Please sign in to comment.