diff --git a/Directory.Packages.props b/Directory.Packages.props index 4584965..4b2d67b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -130,7 +130,7 @@ - + diff --git a/src/Pure.Blazor.Components/Forms/PureInput.razor.cs b/src/Pure.Blazor.Components/Forms/PureInput.razor.cs index f7e99ee..c1c3dd0 100644 --- a/src/Pure.Blazor.Components/Forms/PureInput.razor.cs +++ b/src/Pure.Blazor.Components/Forms/PureInput.razor.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; using Microsoft.AspNetCore.Components.Web; +using Microsoft.Extensions.Logging; using Pure.Blazor.Components.Forms.Validators; using Pure.Blazor.Components.Primitives; @@ -15,12 +16,21 @@ public partial class PureInput private string defaultBorder = "border-gray-200"; private string errorBorder = "border-red-600"; private string? errorMessage; - private object? innerValue; private string? TextValue { - get { return innerValue?.ToString(); } - set { innerValue = value; } + get + { + return Value?.ToString(); + } + set + { + // We abuse the fact that we bind Text-Value instead of Value directly. + // updates are sent via OnValue up to the actual user inputted bind + // Since we never update 'TextValue', only the getter is required to be implemented + // The compiler still requires a setter + Log.LogDebug("TextValue's `set` is not implemented; please use Value's `set`"); + } } // the suffix needs different margins depending on labels and helper text @@ -141,7 +151,6 @@ public void Validate(object? val) protected override void OnInitialized() { - innerValue = Value ?? default; if (Required == true) {