Conditions for custom renderers

Hello,
I’m new to JsonForms - looks like a great project!
I am exploring customRenderers and am puzzled why they don’t seem to obey conditions. I am wanting to display additional help text dependent on the value of some fields but couldn’t get the condition to work. I see the same problem in the seed project and can reproduce as below:

. For example:

  1. Clone the seed project, install dependencies and start
  2. Copy and paste the condition in uiSchema.json from ‘recurrence_interval’ to ‘rating’ which has a custom renderer.
  3. When setting recurrence to ‘Never’ the recurrence_interval control gets hidden, but the rating control is still visible.
    Is this a bug or am I missing something, and do custom renderers need additional configuration to have conditions applied? If I copy and paste the condition into other fields (e.g due date, description) the conditions work just fine.
    Thanks!

This is what the rating control looks like

{
          "type": "Control",
          "scope": "#/properties/rating",
          "rule": {
            "effect": "HIDE",
            "condition": {
              "scope": "#/properties/recurrence",
              "expectedValue": "Never"
            }
          }
 }

Hi @otter606 ,
thanks for your interest in JsonForms :slight_smile:

Rules are not applied automatically to controls - including custom controls - but the calculated enabled and visible state is supplied to controls in their props via the control’s appropriate higher order component.

Each control is then responsible itself to apply the visible and enabled props.

For instance, the vanilla renderer’s InputControl, gets the visible state as prop here: jsonforms/InputControl.tsx at 2bbc64689cdf694daacac7ff5c1f5de6eb540849 · eclipsesource/jsonforms · GitHub

This visible prop is then used to show or hide the control here: jsonforms/InputControl.tsx at 2bbc64689cdf694daacac7ff5c1f5de6eb540849 · eclipsesource/jsonforms · GitHub

The visible prop is injected into the InputControl via HOC withJsonFormsControlProps here: jsonforms/InputControl.tsx at 2bbc64689cdf694daacac7ff5c1f5de6eb540849 · eclipsesource/jsonforms · GitHub

In conclusion, you need to implement hiding/disabling your control based on the supplied visible resp. enabled props. The props are calculated considering the rules in the UI Schema.

I hope that helps,
Lucas

1 Like

Hi Lucas
Thanks for the quick reply! I see now, I thought it unlikely to be a bug but thanks for clarifying.
Best wishes
Richard