Skip to content

2.3.x: FIO-9964: fixed an issue where getComponent returns wrong component when the form includes several components with the same key #238

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

Conversation

TanyaGashtold
Copy link
Contributor

@TanyaGashtold TanyaGashtold commented Apr 4, 2025

Link to Jira Ticket

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

Description

What changed?

When the form has several components with the same key (e.g. components with paths 'repeatedKey' and 'container.repeatedKey'), and you try to get the component using the key 'repeatedKey', the getComponent always returns the component with this key that goes the last in the eachComponent iteration, that is the component with path 'container.repeatedKey'. So, there is no way to get the 'repeatedKey' component. This PR made it so that getComponent returns the component that matches first within the eachComponent iteration. If someone needs to get the 'container.repeatedKey' component, instead of the key, the path should be passed to getComponent.

This fix is for 2.3.x only.
The getComponent in formio/[email protected] works fine because it did not make the key comparison.
The getComponent in core master and [email protected] works fine because those branches have far more changes in pathing/hidden logic and the getComponent is totally refactored.

How has this PR been tested?

Manually + tests

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

…hen the form includes several components with the same key
@brendanbond brendanbond merged commit 4c826bc into 2.3.x Apr 9, 2025
7 of 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