Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React MUI : Allow the translation of enum value used for elementLabelProp #2288

Closed
Maxouwell opened this issue Feb 19, 2024 · 4 comments · Fixed by #2289
Closed

React MUI : Allow the translation of enum value used for elementLabelProp #2288

Maxouwell opened this issue Feb 19, 2024 · 4 comments · Fixed by #2289

Comments

@Maxouwell
Copy link
Contributor

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.
image

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.

@Maxouwell Maxouwell changed the title Allow the translation of enum value used for elementLabelProp React MUI : Allow the translation of enum value used for elementLabelProp Feb 19, 2024
@lucas-koehler
Copy link
Contributor

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?

@Maxouwell
Copy link
Contributor Author

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))

@lucas-koehler
Copy link
Contributor

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.

@Maxouwell
Copy link
Contributor Author

Thanks @sdirix for your help on theses PR !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants