ColorPicker throws NullReferenceException if it cannot parse its value as a valid color.

This commit is contained in:
Atanas Korchev
2022-11-29 19:36:10 +02:00
parent 27859cf183
commit 0e329def1a
2 changed files with 18 additions and 1 deletions

View File

@@ -0,0 +1,16 @@
using Bunit;
using Xunit;
namespace Radzen.Blazor.Tests
{
public class ColorPickerTests
{
[Fact]
public void ColorPicker_ShouldAcceptInvalidValues()
{
using var ctx = new TestContext();
var component = ctx.RenderComponent<RadzenColorPicker>(ComponentParameter.CreateParameter("Value", "invalid"));
}
}
}

View File

@@ -366,7 +366,8 @@ namespace Radzen.Blazor
void Init()
{
var value = Value;
if (String.IsNullOrEmpty(Value))
if (String.IsNullOrEmpty(Value) || RGB.Parse(Value) == null)
{
value = "rgb(255, 255, 255)";
}