Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PureInput Value Patch #95

Merged
merged 3 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading