Skip to content

Commit

Permalink
Merge pull request #95 from pureblazor/PureInput-patch
Browse files Browse the repository at this point in the history
PureInput Value Patch
  • Loading branch information
ModernMAK authored Oct 16, 2024
2 parents 7974549 + 01b70ac commit eeed26d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
<PackageVersion Include="System.Reactive.Async" Version="6.0.0-alpha.18" />
<PackageVersion Include="System.ServiceModel.Primitives" Version="8.0.0" />
<PackageVersion Include="System.Text.Encodings.Web" Version="8.0.0" />
<PackageVersion Include="System.Text.Json" Version="8.0.4" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="Testcontainers" Version="3.8.0" />
<PackageVersion Include="Ulid" Version="1.3.3" />
<PackageVersion Include="Wasmtime" Version="19.0.1" />
Expand Down
17 changes: 13 additions & 4 deletions src/Pure.Blazor.Components/Forms/PureInput.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -141,7 +151,6 @@ public void Validate(object? val)

protected override void OnInitialized()
{
innerValue = Value ?? default;

if (Required == true)
{
Expand Down

0 comments on commit eeed26d

Please sign in to comment.