Listbox throws error after 19.1.63

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.




3 Replies

GK Gayathri KarunaiAnandam Syncfusion Team June 24, 2021 03:16 PM UTC

Hi Joseph, 

We have checked your reported query. We are unable to replicate the reported issue in our latest version. We have prepared a sample based on your suggestion. Please check the sample. 

<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; } 
} 
} 

 

If you are still facing the issue, kindly share the below details. 

  • If possible, try to reproduce the reported issue in provided sample or share the issue reproducible sample.
  • If possible, please share the video of the issue.
  • Please share the Syncfusion version you are using.

Please provide the above requested information, based on that we will check and provide you a better solution quickly. 

Regards, 
Gayathri K 



JT Joseph Tan June 24, 2021 08:52 PM UTC

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" ; 




GK Gayathri KarunaiAnandam Syncfusion Team June 28, 2021 11:12 AM UTC

Hi Joseph, 

We have checked your reported query. We are unable to replicate your reported issue. We have prepared a sample in which we set value in OnInitializedAsync method. Please check the below code snippet. 
 
 
<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; } 
} 
} 

For your reference, we have prepared a sample based on your suggestion. Please check the sample. 

 

If you are still facing the issue, kindly share the below details. 

  • If possible, try to reproduce the reported issue in provided sample or share the issue reproducible sample.
  • If possible, please share the video or Screenshot of the issue.
  • Please share the Syncfusion version you are using.

Please provide the above requested information, based on that we will check and provide you a better solution quickly. 

Regards, 
Gayathri K 


Loader.
Up arrow icon