Hi There,
I have a ListBox which has been working well for a long time (up to 19.1.0.63). After I upgraded to 19.1.0.69, the list box started throwing occasional errors.
<SfListBox CssClass="mt-2" @bind-Value="theUserRoles" DataSource="@rolesList" TItem="EnumData" TValue="string[]">
<ListBoxSelectionSettings Mode="Syncfusion.Blazor.DropDowns.SelectionMode.Single"></ListBoxSelectionSettings>
<ListBoxFieldSettings Text="Name" Value="Name"></ListBoxFieldSettings>
</SfListBox>
Here is the error it often throws (maybe 4 out of 5 times )
System.ArgumentNullException: Value cannot be null. (Parameter 'source') at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) at System.Linq.Enumerable.Where[TSource](IEnumerable`1 source, Func`2 predicate) at Syncfusion.Blazor.DropDowns.SfListBox`2.UpdateFocus(ListOptions`1 item, Boolean remove) at Syncfusion.Blazor.DropDowns.SfListBox`2.RemoveSelection(List`1 list) at Syncfusion.Blazor.DropDowns.SfListBox`2.UpdateSelectedValue(IEnumerable`1 selectedData, Boolean isShiftKey, Boolean isAction, Boolean isCtrlKey) at Syncfusion.Blazor.DropDowns.SfListBox`2.OnParametersSetAsync() at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
I went through the release notes from 19.1.64 - 19.1.69 and there did not seem to be any changes to the listbox, except for the new "Tab" functionality (in dropdown, but I think there are related).
Interestingly, the error is not thrown if I put a breakpoint in OnInitializedAsync() . So, it looks like it could be a timing issue somewhere.
|
<SfListBox TValue="string[]" @bind-Value="Value" DataSource="@Vehicles" TItem="VehicleData">
<ListBoxFieldSettings Text="Text" Value="Text" />
<ListBoxSelectionSettings Mode="Syncfusion.Blazor.DropDowns.SelectionMode.Single"></ListBoxSelectionSettings>
</SfListBox>
@code {
public List<VehicleData> Vehicles = new List<VehicleData> {
new VehicleData { Text = "Hennessey Venom", Id = "Vehicle-01" },
new VehicleData { Text = "Bugatti Chiron", Id = "Vehicle-02" },
new VehicleData { Text = "Bugatti Veyron Super Sport", Id = "Vehicle-03" },
new VehicleData { Text = "SSC Ultimate Aero", Id = "Vehicle-04" },
new VehicleData { Text = "Koenigsegg CCR", Id = "Vehicle-05" },
new VehicleData { Text = "McLaren F1", Id = "Vehicle-06" },
new VehicleData { Text = "Aston Martin One- 77", Id = "Vehicle-07" },
new VehicleData { Text = "Jaguar XJ220", Id = "Vehicle-08" }
};
public string[] Value { get; set; } = new string[] { "Bugatti Chiron" };
public class VehicleData {
public string Text { get; set; }
public string Id { get; set; }
}
} |
I found out how to replicate it.
In OnInitializedAsync(), replace the Value array
Value = new string[] { "Hennessey Venom" };
This is what causes the error, at my end, and my work around is update the array value:
Value[0] = "Hennessey Venom" ;
|
<SfListBox TValue="string[]" @bind-Value="@Value" DataSource="@Vehicles" TItem="VehicleData">
<ListBoxFieldSettings Text="Text" Value="Text" />
<ListBoxSelectionSettings Mode="Syncfusion.Blazor.DropDowns.SelectionMode.Single"></ListBoxSelectionSettings>
</SfListBox>
@code {
public List<VehicleData> Vehicles = new List<VehicleData> {
new VehicleData { Text = "Hennessey Venom", Id = "Vehicle-01" },
new VehicleData { Text = "Bugatti Chiron", Id = "Vehicle-02" },
new VehicleData { Text = "Bugatti Veyron Super Sport", Id = "Vehicle-03" },
new VehicleData { Text = "SSC Ultimate Aero", Id = "Vehicle-04" },
new VehicleData { Text = "Koenigsegg CCR", Id = "Vehicle-05" },
new VehicleData { Text = "McLaren F1", Id = "Vehicle-06" },
new VehicleData { Text = "Aston Martin One- 77", Id = "Vehicle-07" },
new VehicleData { Text = "Jaguar XJ220", Id = "Vehicle-08" }
};
public string[] Value { get; set; } = new string[3];
protected override async Task OnInitializedAsync()
{
Value[0] = "Bugatti Chiron";
Value[1] = "McLaren F1";
Value[2] = "Hennessey Venom";
}
public class VehicleData {
public string Text { get; set; }
public string Id { get; set; }
}
} |