Skip to content

FIO-9934 fixed appearing extra validation messages#237

Merged
johnformio merged 1 commit intomasterfrom
FIO-9934-Wrong-additional-validation-error-message-appears
Apr 3, 2025
Merged

FIO-9934 fixed appearing extra validation messages#237
johnformio merged 1 commit intomasterfrom
FIO-9934-Wrong-additional-validation-error-message-appears

Conversation

@HannaKurban
Copy link
Copy Markdown
Contributor

Link to Jira Ticket

https://formio.atlassian.net/browse/FIO-9934

Description

The root of the problem of extra errors is the fact that the validateComponent method, and with it the shouldSkipValidation method, is not called for child components inside the EditGrid and DataGrid components.
For example, there is a form with an EditGrid (and a TextField nested in it) and a DataGrid (and a required Number field nested in it) components. By default, these components are displayed. When editing the form, this.errors object includes "required" and "unsavedRowsError" errors and this is expected. Next, the user decides to hide the EditGrid and DataGrid components, therefore their value set to undefined and the validation process starts. Due to the fact that the iteration of components nested in the DataGrid and EditGrid is skipped in the eachComponentData method, the validation is also skipped for nested components, and therefore the shouldSkipValidation method is skipped for all nested components, which leads to errors remaining from the this.errors object for these components. Therefore, the this.errors object continues to store errors of already hidden components inside the DataGrid and EditGrid.
This problem is relevant only for DataGrid and EditGrid components, since for all other components with nested fields (for example, container or layout components), all child components are iterated and the validateComponent and shouldSkipValidation methods are called for each. So the problem was fixed by updating condition for the DataGrid and EditGrid components in eachComponentData method.

Breaking Changes / Backwards Compatibility

n/a

Dependencies

n/a

How has this PR been tested?

Automated test was added, some tests were updated/ All tests pass locally

Checklist:

  • I have completed the above PR template
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • My changes include tests that prove my fix is effective (or that my feature works as intended)
  • New and existing unit/integration tests pass locally with my changes
  • Any dependent changes have corresponding PRs that are listed above

@johnformio johnformio merged commit fc8960e into master Apr 3, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants