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

RadzenDropDown: when using multi-select, collections bound to value are set to null on clear #1401

Open
pianomanjh opened this issue Feb 29, 2024 · 0 comments

Comments

@pianomanjh
Copy link
Contributor

pianomanjh commented Feb 29, 2024

Describe the bug
When using RadzenDropDown to make multiple selections bound to a collection, with AllowClear set to true, a user can click to clear all choices from the collection. This results in the bound collection property being set to null, instead of clearing the collection entries. I understand this may be by design, but, especially when using nullable annotations in a codebase, results in easy-to-miss null reference exceptions.

To Reproduce
Steps to reproduce the behavior:

public class Foo
{
    public ICollection<string> Settings { get; set; } = new List<string>();
}

var foo = new Foo() { Settings = ["Two"] };
var values = new string[] { "One", "Two", "Three" };

<RadzenDropDown Multiple="true" AllowClear="true" @bind-Value="@foo" Data="@values" />

After clicking the X in the control to clear the selections, foo.Settings is null instead of an empty collection.

Expected behavior
If the property bound to value started as a non-null collection instance, I would expect that collection to remain, but be empty.

I understand this may be breaking behavior, so, as a potential mitigation, if the property bound to value started as null, we could have that property be set to null on clear...

Additional context
If this is something the team is ok changing, let me know and I'm happy to post a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant