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

uischema props are not propagated to Layout renderer when using a material Object Renderer #2314

Open
Sewdn opened this issue Apr 5, 2024 · 1 comment

Comments

@Sewdn
Copy link

Sewdn commented Apr 5, 2024

Describe the bug

When you add a UI Control for a complex object, the default behaviour is to wrap the UI with a Group or VerticalLayout.
When extra props are added to customize the behaviour for this Layout Renderers, these are not available in the Customize Group or VerticalLayout Renderer.

Expected behavior

I would expect all props that are set in the uischema to be propagated to the Layout renderer as well.

Steps to reproduce the issue

  1. Add a custom Group Renderer that checks for the existence of an additional property test on the uischema
  2. Add a Control to the layout for a compound object property and add this additional test property.
  3. notice that the form for the object is rendered as a group, but the custom Group renderer is not being used, although the test property was available on the uischema of the object Control.
{
  uischema: {
    type: 'VerticalLayout',
    elements: [
      {
        type: 'Control',
        acl: 'PRIVATE',
        label: 'an ACL compound object',
        asCard: false,
        preset: 'header',
        scope: '#/properties/reinforcement',
      },
    ],
  },
  schema: {
    type: 'object',
    properties: {
      reinforcement: {
        type: 'object',
        properties: {
          type: {
            type: 'string',
            enum: ['sunk', 'embedded', 'hybrid'],
          },
          strength: {
            type: 'number',
            unit: '<sup>kg</sup>&frasl;<sub>m<sup>2</sup></sub>',
          },
        },
      },
    },
  },

Screenshots

No response

Which Version of JSON Forms are you using?

v3.2.1

Framework

React

RendererSet

Material

Additional context

Just spreading all of the uischema props, fixes this:

findUISchema(
        // @ts-expect-error
        uischemas,
        schema,
        uischema.scope,
        path,
        () =>
          isEmpty(path)
            ? Generate.uiSchema(schema, 'VerticalLayout', undefined, rootSchema)
            : {
                ...uischema,
                ...Generate.uiSchema(schema, 'Group', undefined, rootSchema),
                label,
                // preset: 'header',
                // asCard: false,
              },
        uischema,
        rootSchema,
      ),

I setup a custom Object Renderer wit higher priority to do this, but I would suggest to consider this adding it to core behaviour (not only for Group Layouts, but also for VerticalLayout and other renderers and frameworks)

@lucas-koehler
Copy link
Contributor

Hi @Sewdn , thank you for the suggestion. I will discuss with the team whether that is something we want to support. Usually, props of UI Schema elements themselves are not propagated down. A specific detail schema for an object can also be provided by using the uischemas prop of JsonForms.

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

No branches or pull requests

2 participants