formio / formio.js

JavaScript powered Forms with JSON Form Builder
https://formio.github.io/formio.js
MIT License
1.83k stars 1.04k forks source link

The path of a validation error points always to the last inner edit grid child #5570

Open bogist opened 2 months ago

bogist commented 2 months ago

Describe the bug When there are invalid entries in some of the rows of an inner edit grid of a parent edit grid, we will notice that if we enable the validations for the given form then we will see that the links in the alerts will point to a relative path that once clicked it will redirect to the last row of the inner edit grid of the last row of the parent edit grid.

Version/Branch latest 4.19

To Reproduce Steps to reproduce the behavior:

  1. Create a form that contains the following:
    • Parent edit grid that allows draft rows with invalid input;
    • Each entry of the parent edit grid to contain an inner edit grid that allows draft rows with invalid input;
    • Each entry of the inner edit grid to have an input text field with any given validation required or custom.
  2. Add a button that once clicked it will display the validation errors of the form
  3. Add new entry in the parent edit grid, with two new inner edit grid entries where the first one has an invalid input and the second is valid
  4. Add another new entry in the parent edit grid only this time, we add a valid entry in the inner edit grid
  5. Save all rows
  6. Click the button to validate the form
  7. Click on one of the inner grid messages that point to a relative path to the inner edit grid sections(Not the input field message but the one that is referring to invalid rows of the inner edit grid)
  8. See that you are redirected to the valid entry of the last row of the parent edit grid, of the last inner edit grid component

Expected behavior Every link should point to each individual path of the given component and not redirect to the last entry of the edit grid as this creates confussion

Context The above scenario can be reproduce on https://formio.github.io/formio.js/app/sandbox with the following details:

jeriah-formio commented 1 month ago

This seems to be resolved in FJS 4.19.1.

The only validation message that will redirect the focus to a component path is the field the validation pertains to.