Skip to content

Commit

Permalink
RadzenNumeric defaults to min value on tab
Browse files Browse the repository at this point in the history
  • Loading branch information
enchev committed Aug 18, 2023
1 parent 8476fdb commit 933c820
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 15 additions & 1 deletion Radzen.Blazor/RadzenNumeric.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private string getOnInput()
object minArg = Min;
object maxArg = Max;

return (Min != null || Max != null) ? $@"Radzen.numericOnInput(event, {minArg ?? "null"}, {maxArg ?? "null"})" : "";
return (Min != null || Max != null) ? $@"Radzen.numericOnInput(event, {minArg ?? "null"}, {maxArg ?? "null"}, {IsNullable})" : "";
}

private string getOnPaste()
Expand All @@ -54,6 +54,20 @@ private string getOnPaste()
return Min != null || Max != null ? $@"Radzen.numericOnPaste(event, {minArg ?? "null"}, {maxArg ?? "null"})" : "";
}

bool? isNullable;
bool IsNullable
{
get
{
if (isNullable == null)
{
isNullable = typeof(TValue).IsGenericType && typeof(TValue).GetGenericTypeDefinition() == typeof(Nullable<>);
}

return isNullable.Value;
}
}

async System.Threading.Tasks.Task UpdateValueWithStep(bool stepUp)
{
if (Disabled || ReadOnly)
Expand Down
4 changes: 2 additions & 2 deletions Radzen.Blazor/wwwroot/Radzen.Blazor.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,10 +627,10 @@ window.Radzen = {
e.preventDefault();
}
},
numericOnInput: function (e, min, max) {
numericOnInput: function (e, min, max, isNullable) {
var value = e.target.value;

if (value == '' && min != null) {
if (!isNullable && value == '' && min != null) {
e.target.value = min;
}

Expand Down

0 comments on commit 933c820

Please sign in to comment.