Passing invalid value to Multiselect breaks the UI

1 Answer 6 Views
MultiSelect
Jie
Top achievements
Rank 3
Iron
Iron
Iron
Jie asked on 26 Apr 2024, 12:21 AM

Hi,

 

If pass a invalid value to MultiSelect, it will break the UI with null pointer exception. Please see this example:

https://codesandbox.io/p/sandbox/zen-pasteur-fw7rrt?file=%2Fapp%2Fmain.jsx%3A13%2C20

 

This only happens if data is an array of objects, and textField property is used.

It is possible invalid values are passed to multiselect when it is a controlled component. I am hoping MultiSelect can handle data error mor gracefully.

 

Thanks,

Jie

1 Answer, 1 is accepted

Sort by
0
Accepted
Wissam
Telerik team
answered on 29 Apr 2024, 12:26 PM

Hi, Jie,

This is expected since when binding to an array of objects, the value should also be an object. Setting the value to a primitive value will result in an error, since the data is not set to an array of primitive values. You can check the difference here:

On the other hand, I understand they you know the difference, but you want a more accurate error message. In this case, I can suggest validating if the format of the value is correct or not, and if it is not throw a JavaScript error message.

Another option would be to log a feature request to throw a more accurate internal error message for all components that allow data binding to different formats:

If you have any further questions on this matter, please let me know.

Regards,
Wissam
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources!

Tags
MultiSelect
Asked by
Jie
Top achievements
Rank 3
Iron
Iron
Iron
Answers by
Wissam
Telerik team
Share this question
or