Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIO-9299: ensure eachComponent does not mutate a component's path #184

Merged
merged 2 commits into from
Nov 4, 2024

Conversation

brendanbond
Copy link
Contributor

@brendanbond brendanbond commented Nov 4, 2024

Link to Jira Ticket

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

Description

The eachComponent and eachComponentAsync functions previously mutated a component's path property by adding a non-enumerable property. This is necessary for the processors to track a component's path throughout a process' lifetime. However, many other systems utilize eachComponent as a utility function, and presumably none of these require path to be tracked at the eachComponent level. For instance, Edit Grid calls eachComponent in its default template (and a couple other places), and the fact that eachComponent contained the path mutation side-effect meant that certain operations on the client would have incorrect paths. Imagine, for example, calling eachComponent within the Edit Grid - suddenly, paths that were once editGrid[0].textField are suddenly mutated to textField and removed from the componentsMap, as in the bug presented in FIO-9299.

This PR moves the definition of the path non-enumerable property to the subroutine that needs it, processOne, thereby leaving eachComponent without the side-effect and reducing the potential for bugs involving pathing.

Breaking Changes / Backwards Compatibility

n/a

Dependencies

n/a

How has this PR been tested?

I've added an automated test to ensure that eachComponent does not mutate the path directly. Since this PR also effectively reverts #180 I've gone ahead and manually ensured that that issue is still resolved.

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 642240b into master Nov 4, 2024
8 checks passed
lane-formio pushed a commit that referenced this pull request Nov 4, 2024
* move path mutation into processOne and out of eachComponent; update fn signatures

* add tests; refactor test organization
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.

3 participants