eclipsesource / jsonforms

Customizable JSON Schema-based forms with React, Angular and Vue support out of the box.
http://jsonforms.io
Other
2.22k stars 373 forks source link

Unexpected oneOf re-rendering when filling other schema fields [React Material] #2342

Open andrecchia opened 5 months ago

andrecchia commented 5 months ago

Describe the bug

Starting from version 3.2.0, with React Material renderers, I observed that any keyboard input in any field triggers a rerender of the oneOf elements.

Expected behavior

The oneOf elements should rerender only when there is keyboard input within their own fields, as was happening in version 3.1.0

Steps to reproduce the issue

Screenshots

No response

Which Version of JSON Forms are you using?

v3.3.0

Framework

React

RendererSet

Material

Additional context

No response

sdirix commented 5 months ago

Hi @andrecchia,

Thanks for the detailed report! Much appreciated!

It seems we accidentally broke the memo barrier somewhere in between the versions. Did you already check via the React Dev Tooling which prop is responsible for the rerendering of our components?

andrecchia commented 5 months ago

Hi @sdirix, sorry for the very late reply. Actually I tried but I could not get the responsible of the rerendering, I am not so used to React Dev Tooling. I plan to check for it again since in these days I am debugging my application, I will get you updated.

LukasBoll commented 4 months ago

This error occurs in the OnOf-renderer and the Array-renderer. They use a set of translated texts (e.g. for the confirmation dialog). But we create a new translations object each time when mapping the JSONforms state to component props in the core module: https://github.com/eclipsesource/jsonforms/blob/c3cead71d08ff11837bdeb5fbea66e5313137218/packages/core/src/i18n/i18nUtil.ts#L181-L192

https://github.com/eclipsesource/jsonforms/blob/c3cead71d08ff11837bdeb5fbea66e5313137218/packages/core/src/i18n/i18nUtil.ts#L167-L179

sdirix commented 4 months ago

Good find. This means we need to handle them differently in the bindings to avoid breaking the memo barrier. Either by customizing the memo handling or by binding them separately (in a transparent fashion).