appsmith icon indicating copy to clipboard operation
appsmith copied to clipboard

[Bug]: JSONForm Select field displays incorrect error message "duplicate values" when options array has labels but no values property

Open GreenFlux opened this issue 2 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Description

The Select field type in a JSONForm is missing some of the newer features of the standard Select widget. It requires an array of objects with a label and value property, and lacks the UI options to assign other property names like the standard Select Widget.

JSONForm Select Field Screenshot 2024-05-27 at 8 15 14 AM Standard Select Widget Screenshot 2024-05-27 at 8 16 26 AM

If you provide an array of objects with other property names, the first error tells you you're missing a label property. Helpful. Screenshot 2024-05-27 at 8 25 18 AM

If you map the data and provide a label but no value, the error incorrectly says that there are duplicate values, instead of telling you to add a value property.

The inconsistencies between the Select widget, and select fields in a table or JSONForm make it difficult enough to work with select options. But this error is misleading and makes it even harder for users to figure out.

Screenshot 2024-05-27 at 8 21 03 AM Screenshot 2024-05-27 at 8 21 21 AM

Also, the evaluated value shows an empty array, even though the binding is returning a valid JSON array of unique objects.

Steps To Reproduce

Provide an array of objects to the JSONForm Select field, with unique labels, but no value property.

[{"label":"Development"},{"label":"Marketing"},{"label":"Sales"},{"label":"UX/UI"},{"label":"Product"},{"label":"Support"}]

Public Sample App

No response

Environment

Production

Severity

Medium (Frustrating UX)

Issue video log

No response

Version

Appsmith v1.27.0-SNAPSHOT

GreenFlux avatar May 27 '24 12:05 GreenFlux

Hi @contributor-support, I'd like to pick this up. The cause is in validateArray (app/client/src/workers/Evaluation/validations.ts): the unique-keys check runs before the per-entry validation, and entries without a value key compare as undefined === undefined, so it reports "Duplicate values" and stops before "Missing required key: value" is shown. My plan is to skip undefined keys in the uniqueness comparison so real duplicates are still caught, with unit tests in validations.test.ts. Could you assign it to me? Since this is assigned to the pod, please let me know if someone is already on it.

utsxvrai avatar Nov 21 '26 11:11 utsxvrai