Hi @sdirix i’m having the same issue now with a slightly different part of my code. I’m trying to implement some functionality that following a change to a specific field, updates other instances where that field is referenced.
To provide a bit more context I have implemented enumerations based on values in some other part of data. As a simplified example of this is I have
{
"entities": [
{
"name": "person",
"code": "PER"
},
{
"name": "claim",
"code": "CLA"
},
{
"name": "location",
"code": "LOC"
}
],
"relationships": [
{
"fromEntity": "person",
"toEntity": "claim"
},
{
"fromEntity": "location",
"toEntity": "claim"
}
]
}
And a custom renderer that I use in my relationship from and to field to get the values from entities.items.properties.name and display them in a drop down list (like with the enum control). As part of this I also construct and maintain a list of dependencies that for the previous example would look like:
[
{"from": "relationships.0.fromEntity", "to": "entities.0.name"},
{"from": "relationships.0.toEntity", "to": "entities.1.name"},
{"from": "relationships.1.fromEntity", "to": "entities.2.name"},
{"from": "relationships.1.toEntity", "to": "entities.1.name"},
]
And using this information I know that if any of my to dependencies get’s updated. I get all the associated froms and also update those. So if I updated the claim → insurance_claim I would know that I also need to update both of the relationships that reference the claim. My current attempt to implement this is by extending the handleChange function in the MaterialInputControl so it looks like:
const ctx = useJsonForms();
const handleChangeExt = (path: string, value: any) => {
if (depedencygraph.some(dep => dep.to === props.path)){
depedencygraph.forEach(dep => {
if (dep.to === props.path){
ctx.dispatch!(Actions.update(dep.from, () => value));
}
})
}
props.handleChange(path, value)
}
where depedencyGraph looks like the array from the previous code block.
The problem i’m facing at the moment is that the generic onChange function I pass to the JsonForms component seems to be running on an infinite loop even though in my example the ctx.dispatch that updates dependent paths is only called 3 times.