eufemia icon indicating copy to clipboard operation
eufemia copied to clipboard

feat(Forms): add `isValid` to Form.Visibility for showing content based on the validation of a field

Open tujoworker opened this issue 5 months ago • 5 comments

As of now, the Visibility does only react on data content, but not on validation. This PR is an attempt to add support for showing something based on the validation result by another field:

<Form.Visibility
  visibleWhen={{
    path: '/foo',
    isValid: true,
  }}
>
  <Value.Name.First path="/foo" />
</Form.Visibility>

Here is a demo.

Why first act on the blur event?

To avoid hiding/showing its content during e.g. typing, it will wait until the field has blurred.

E.g. the name field does validate negatively when a space is added after a name. During typing are we going then from false to true to false several times.

Screenshot 2024-10-01 at 10 32 22

This blur behavior could for sure be omitted with a property such as continuously: true (a little bit like continuousValidation).

tujoworker avatar Oct 01 '24 09:10 tujoworker