jsonforms
jsonforms copied to clipboard
React MUI : Allow the translation of enum value used for elementLabelProp
Describe the bug
At the moment, when an enum field is used in a elementLabelProp option, the raw enum value is used, without allowing to translate it via the translate function.
Expected behavior
The value should be sent to the translate function for customizing.
Steps to reproduce the issue
Create a JsonForms with :
Json Schema
{
type: 'array',
items: {
type: 'object',
properties: {
message: {
type: 'string',
maxLength: 3,
},
messageType: {
type: 'string',
enum: ['MSG_TYPE_1', 'MSG_TYPE_2'],
},
},
},
}
UI Schema :
{
type: 'Control',
scope: '#',
options: {
elementLabelProp: 'messageType',
detail: {
type: 'HorizontalLayout',
elements: [
{ type: 'Control', scope: '#/properties/message' },
{ type: 'Control', scope: '#/properties/messageType' },
],
},
},
}
Data :
[
{
message: 'El Barto was here',
messageType: 'MSG_TYPE_1',
},
{
message: 'Yolo',
},
]
Screenshots
No response
Which Version of JSON Forms are you using?
v.3.2.1
Framework
React
RendererSet
Material
Additional context
I think an old bug was repurposed to highlight this behavior but I can't find it anymore.
Hi @Maxouwell , thanks for bringing this up :) I agree that this would be a nice extension to the behavior of the ExpandPanelRenderer. Would you like to contribute this?
Hi @lucas-koehler ! Has you've seen, I already submited a PR for this :)
As a side question, what would be the best way to check with you if something is a bug or not ? I came across some odd behavior while doing the PR that I'm not sure if it was intended. Should I open a bug for each one ? (on the top of my mind, MaterialEnumArrayRenderer that could have a FormLabel, and a description, and that does not support const value (but it means having withJsonFormsMultiEnumProps addind const support, and it impact the core and the other type of renderer, which I'm not able to fix/expand))
Hi @Maxouwell ,
generally opening issues is the best way to do that. If the behavior is intended the issue can always be closed again and we have a searchable record of the behavior :)
In your concrete example, I would not classift the MaterialEnumArrayRenderer not having a FormLabel or description a bug. More like a feature that could be extended. However, it is of course still fine to open an issue for that to document and possibly fix it.
Thanks @sdirix for your help on theses PR !