elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.77k stars 8.17k forks source link

[Form Lib] Interaction with EuiComboBox causes duplicate errors to be appended to form field #183779

Open rylnd opened 4 months ago

rylnd commented 4 months ago

Summary

This was originally surfaced as an issue with a specific validation for a specific field within the Detection Engine. However, on inspection it appears to be a general issue with the form library and (at least) EUI's ComboBox component.

Steps to Reproduce

  1. Define a combobox field (type: FIELD_TYPES.COMBO_BOX) with an emptyField validator
  2. Clear the field, and observe the error appear as expected
  3. Focus off (e.g. blur) the combobox field, and observe no additional validation/error
  4. Add a space (" ") character to the field
  5. Blur the field again, and observe that an additional error is appended to the field's error list after every subsequent blur (validation) event

Additional Notes

While this behavior may be more general than described above, it seems centered around the following behaviors:

  1. When the combobox contains an invalid value, the validation result is appended to the existing list of errors
  2. When the combobox contains an invalid value, the validator is called with only that single value (not the full array of values) as the value argument
    • In the original issue, we had an additional validation excluding "*" from being a valid option, so one could also use a "*" in step 4 above to reproduce this behavior.
elasticmachine commented 4 months ago

Pinging @elastic/eui-team (EUI)

cee-chen commented 4 months ago

However, on inspection it appears to be a general issue with the form library and (at least) EUI's ComboBox component.

From the PR description alone, it's not clear to me how this issue is baseline to EuiComboBox. Could you help provide minimum repro steps within EUI's combobox docs or a minimum repro Codesandbox?