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

Referencing the same dependent in multiple dependency possibilities deletes an element #8

Open
yaoyuyang opened this issue Dec 19, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@yaoyuyang
Copy link
Member

Comment:
When adding dependencies for an element, if the same child element is selected twice (among two different dependency cards), then an element will be deleted (not necessarily the child element that gets selected twice).

Suggested Approach:
This issue is likely related to the issue regarding rendering an enum or option based on another element’s value.
This issue ultimately stems from the fact that the “value based dependency” is ultimately an abstraction and simplification of the true oneOf dependency that it is based on. Right now, in src/formBuilder/utils.js, the issue is likely coming up with this if statement:

if (!Object.keys(elementDict).includes(parameter)) {
    elementDict[parameter] = {};
    elementCount += 1;
}

the elementDict is populated with form elements that the form builder has already “seen”. Therefore, when a child is marked as a dependent twice, it will appear twice in the dataSchema’s corresponding dependency, however, it will only be parsed the first time (the second time around, the if statement will resolve to false). For both of these issues, it may be necessary to raise a warning to the user if the schema detects that an element the appears in the dependency section appears in more than one dependency possibility.

This should avoid doing the same with “base” elements that exist in the root properties section, because we actually do support, and expect, those elements to appear multiple times (for example, a dropdown that renders things differently based on the value should and does appropriately appear in multiple dependency possibilities). As such, in the copied statement, instead of elementDict[parameter] = {};, we should store this key value pairing in a different hash table, to handle those cases differently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants