It is observed that for the JSONForm widget whenever we have a field that recieves the data as Array of objects or nested object structure then the defaultValue is getting evaluated late in the cycles.
Consider the following scenario:
For the Array field type, the defaultValue property is not getting evaluated correctly. Since it is an array field we expect that the value should directly get evaluated to an array but instead it gets first evaluated to string and in the later cycles it resolves to array.
Here is the observations while debugging:
1st Cycle:Validation config:STRING
As you can see from above even if the validation config has changed to ARRAY type in 2nd eval but still in the eval tree we get string value.
Here the expected behaviour should be that the defaultValue should get evaluated in the second cycle itself.
Steps To Reproduce
Create a mongo query that fetches the data. Make sure the data has some nested structured data like Array of objects. You can make use of sample movies DB which is a mongo db datasource.
Find this query to a table.
Dnd a JSON form and bind it's sourceData like this: Table1.selectedRow.
Now try to deselect a row in a table and select the row again.
Is there an existing issue for this?
Description
It is observed that for the JSONForm widget whenever we have a field that recieves the data as Array of objects or nested object structure then the
defaultValue
is getting evaluated late in the cycles.Consider the following scenario: For the Array field type, the
defaultValue
property is not getting evaluated correctly. Since it is an array field we expect that the value should directly get evaluated to an array but instead it gets first evaluated to string and in the later cycles it resolves to array.Here is the observations while debugging: 1st Cycle: Validation config:
STRING
evalTree output:
schema._root_schema_.genres.defaultValue = '[{"name":"Action","id":28},{"name":"Adventure","id":12},{"name":"Science Fiction","id":878}]'
2nd Cycle: Validation config:
ARRAY
evalTree output:
same as above string value
3rd Cycle: Validation config:
ARRAY
evalTree output: = Gives the correct array i.e.
[ { "name": "Action", "id": 28 }, { "name": "Adventure", "id": 12 }, { "name": "Science Fiction", "id": 878 } ]
As you can see from above even if the validation config has changed to
ARRAY
type in 2nd eval but still in the eval tree we get string value.Here the expected behaviour should be that the
defaultValue
should get evaluated in the second cycle itself.Steps To Reproduce
dataTree
log during the above cyclesPublic Sample App
No response
Environment
Production
Issue video log
No response
Version
Cloud