jsonforms
jsonforms copied to clipboard
Uncaught SyntaxError when remounting a component with JsonForms and a rule in uischema
Describe the bug
I have a component that is mounted and unmounted by a toggle button. After mounting it 3 times (!!!), this error is thrown.
"Uncaught SyntaxError: Unexpected token ':'"
https://github.com/eclipsesource/jsonforms/assets/921303/69f7d7f3-45e3-4507-b414-a0d51796b035
This error only appears if the uischema has defined a rule. And I can avoid this error by providing a global one-time initiated AJV.
Although this is probably an AJV issue, but i could not find any further information on why this is the case and what the best practice is for such behavior on mounted and unmounted formulars.
Expected behavior
I have built a small app with which the error can be reproduced: https://79dmkr-5173.csb.app/
if you turn the form on and off the first 2 times, nothing happens. only the third time the error appears
Steps to reproduce the issue
- Go to https://79dmkr-5173.csb.app/ or https://codesandbox.io/p/sandbox/loving-yonath-79dmkr
- Click 3 times on 'hide form'
- Open Developer Console
- See error
Screenshots
No response
In which browser are you experiencing the issue?
Google Chrome 118., Edge 118., Opera 104
Which Version of JSON Forms are you using?
v3.1.0
Framework
Vue 3
RendererSet
Vanilla
Additional context
Find the app here: https://79dmkr-5173.csb.app/ or https://codesandbox.io/p/sandbox/loving-yonath-79dmkr
Update: I have now tried various browsers and updated them to the latest versions. The bug no longer appears in the latest Chrome version 119.
Nevertheless, any idea why this is happening? Regardless of the browser version, I would like to have this problem solved for myself and my clients.
Hi @davewwww,
Oh wow that is super weird. Yes, the error is thrown in AJV. It seems the AJV code generation fails for the schema. I never saw that before so I can't give any hint there. Looking at the error message, it seems somehow a weird {"_items":[""]}
is generated which really serves no purpose.
We could check what we hand over to AJV after hide/show. Maybe we hand over a broken schema.