Open sjamaan opened 4 weeks ago
@sjamaan Thank you for brining this up. We were able to replicate the behavior and created a ticket FIO-8443 for dev review.
After review, we don't expect to resource a developer to investigate this in the near future but would be happy to review any contributions to resolve this behavior.
After review, we don't expect to resource a developer to investigate this in the near future but would be happy to review any contributions to resolve this behavior.
Hi @lane-formio,
Thanks for reviewing the issue. I saw the jsfiddle project that the OP provided, but that's not a practical workaround for my team.
Since this has been deemed low-priority, what is the official work-around for this issue if one is using React?
Describe the bug
When using the
radio
orselectboxes
type withdataSrc: 'url'
, thesetSubmission
function and associated setter crash when there is a missingmetadata
property on submission.It appears to be caused by inconsistencies across the code base regarding how
metadata
is queried. For example, in radio.js, there's this code insetItem
, but innormalizeValue
when theisSelectUrl
getter returnstrue
, the same sort of code (where the crash happens) does not guard for missing ametadata
property - it simply assumes it to always be there.In other places, like here, the lodash
_.get
function is used with a path.To make things worse, if the "right" combination of form elements are used, this error doesn't occur because some other function may have already set the metadata, so not all the buggy code will always trip over it.
Perhaps a simple way to fix this is to do the check in
setSubmission
before calling any of the other functions? Then the guards can probably be removed everywhere, making for easier to read code. Alternatively, all the places wheremetadata
is used should be audited and fixed to ensuremetadata
gets set when missing before attempting to read sub-properties ofmetadata
.Version/Branch
4.19 (but also older versions, and 5.0 looks affected too)
To Reproduce
See this jsfiddle for an example: https://jsfiddle.net/dj7nv1rw/
If you click one of the select boxes, the input gets updated, but then it crashes (see console). If you click another box it won't update the input anymore. If you uncomment the line mentioned in the comment, it doesn't crash anymore. I consider this a workaround - according to the documentation, this should not be necessary.
Expected behavior
No crash when
metadata
is missing from submission.