# Misunderstanding something about scope

**URL:** <https://jsonforms.discourse.group/t/misunderstanding-something-about-scope/17>\
**Category:** General\
**Created:** [March 10, 2021, 9:50pm UTC](https://jsonforms.discourse.group/t/misunderstanding-something-about-scope/17 "2021-03-10T21:50:48Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [March 10, 2021, 9:50pm UTC](https://jsonforms.discourse.group/t/misunderstanding-something-about-scope/17/1 "2021-03-10T21:50:48Z")

</div>

Hi all, I’m losing my mind over this error a little bit. I’m trying to put a Categorization inside another Categorization, and this appears to be breaking something (thought I’m really just guessing about the cause at this point). Code in the comments:

_[[original thread](https://spectrum.chat/jsonforms/general/misunderstanding-something-about-scope~7c2f0f67-e64c-4eae-b714-b1dfce4a5138) by henry-oconnor]_

---

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [March 10, 2021, 9:51pm UTC](https://jsonforms.discourse.group/t/misunderstanding-something-about-scope/17/2 "2021-03-10T21:51:44Z")

</div>

_[henry-oconnor]_

The topmost Control with scope #/properties/ID renders as a textarea, but the one at the bottom does not. What is causing the scope to change inside that second categorization (if that’s even what’s happening)?

```auto
  "type": "Categorization",
  "elements": [
    {
      "type": "Category",
      "label": "Experiments",
      "elements": [
        {
          "type": "ListWithDetail",
          "scope": "#/properties/experiments",
          "options": {
            "labelRef": "#/items/properties/ID",
            "detail": {
              "type": "VerticalLayout",
              "elements": [
                {
                  "type": "HorizontalLayout",
                  "elements": [
                    {
                      "type": "Control",
                      "scope": "#/properties/ID"
                    },
                    {
                      "type": "Control",
                      "scope": "#/properties/preExperimentMeasurementIDs"
                    },
                    {
                      "type": "Control",
                      "scope": "#/properties/postExperimentMeasurementIDs"
                    }
                  ]
                },
                {
                  "type": "Categorization",
                  "elements": [
                    {
                      "type": "Category",
                      "label": "Sequential",
                      "elements": [
                        {
                          "type": "VerticalLayout",
                          "elements": [
                            {
                              "type": "Control", 
                              "scope": "#/properties/ID"
                            },

```

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [March 11, 2021, 8:36am UTC](https://jsonforms.discourse.group/t/misunderstanding-something-about-scope/17/3 "2021-03-11T08:36:41Z")

</div>

Hi @henry-oconnor(henry-oconnor), can you provide a complete example with which I can reproduce the issue, i.e. a JSON Schema and UI Schema? From a first glance both controls should render the same way, as `Categorization` is only a visual element and doesn’t affect scope resolution.

You said that your control renders as a textarea. As I don’t see a `options: { multi: true }`, are you using a custom renderer?

---

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [March 11, 2021, 2:54pm UTC](https://jsonforms.discourse.group/t/misunderstanding-something-about-scope/17/4 "2021-03-11T14:54:11Z")

</div>

_[henry-oconnor]_

Sorry, I meant textfield. Here are the schemas:

UI Schema

```auto
{
  "type": "Categorization",
  "elements": [
    {
      "type": "Category",
      "label": "Experiments",
      "elements": [
        {
          "type": "ListWithDetail",
          "scope": "#/properties/experiments",
          "options": {
            "labelRef": "#/items/properties/ID",
            "detail": {
              "type": "VerticalLayout",
              "elements": [
                {
                  "type": "HorizontalLayout",
                  "elements": [
                    {
                      "type": "Control",
                      "scope": "#/properties/ID"
                    }
                  ]
                },
                {
                  "type": "Categorization",
                  "elements": [
                    {
                      "type": "Category",
                      "label": "Sequential",
                      "elements": [
                        {
                          "type": "VerticalLayout",
                          "elements": [
                            {
                              "type": "Control",
                              "scope": "#/properties/ID"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          }
        }
      ]
    }
  ]
}

```

Schema

```auto
{
    "$id": "#schema",
    "type": "object",
    "properties": {
      "experiments": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "ID": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "additionalItems": false
        }
      }
    },
    "required": [
      "experiments"
    ]
  }

```

Data

```auto
{
    "experiments": [
        {
            "ID": "Experiment 1"
        }
    ]
}

```

---

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [March 11, 2021, 3:00pm UTC](https://jsonforms.discourse.group/t/misunderstanding-something-about-scope/17/5 "2021-03-11T15:00:33Z")

</div>

_[henry-oconnor]_

 ![](https://global.discourse-cdn.com/free1/uploads/jsonforms/original/1X/dbd6d6673b7c88d2c91199bbb7e04155ccbf30c2.png)

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [March 11, 2021, 3:25pm UTC](https://jsonforms.discourse.group/t/misunderstanding-something-about-scope/17/6 "2021-03-11T15:25:36Z")

</div>

![](https://global.discourse-cdn.com/free1/uploads/jsonforms/original/1X/8d58b9ccf768f52306319c96429566e202e8a99b.png)

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [March 11, 2021, 3:25pm UTC](https://jsonforms.discourse.group/t/misunderstanding-something-about-scope/17/7 "2021-03-11T15:25:39Z")

</div>

I can’t reproduce the issue. I tried it with the current JSON Forms `2.5.0`, with the previous version `2.4.1` and also with the prerelease `2.5.1-alpha.1` and it worked for me in all of them.

Are your JSON Forms versions aligned, i.e. are you using the same version for `@jsonforms/core`, `@jsonforms/react` and `@jsonforms/material-renderers`? What else do you do besides invoking JSON Forms? Could you share the code?

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [March 11, 2021, 3:28pm UTC](https://jsonforms.discourse.group/t/misunderstanding-something-about-scope/17/8 "2021-03-11T15:28:37Z")

</div>

Ah I just realized… You’re using the Angular variant of JSON Forms. There I can reproduce the issue.

---

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [March 11, 2021, 3:31pm UTC](https://jsonforms.discourse.group/t/misunderstanding-something-about-scope/17/9 "2021-03-11T15:31:30Z")

</div>

_[henry-oconnor]_

Yeah, I should have mentioned that. Damn, I was hoping it was a mistake on my part.

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [March 11, 2021, 3:33pm UTC](https://jsonforms.discourse.group/t/misunderstanding-something-about-scope/17/10 "2021-03-11T15:33:42Z")

</div>

Created an issue: [#1713](https://github.com/eclipsesource/jsonforms/issues/1713)

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [March 11, 2021, 3:42pm UTC](https://jsonforms.discourse.group/t/misunderstanding-something-about-scope/17/11 "2021-03-11T15:42:18Z")

</div>

The fix is probably not too hard. I guess that somewhere the correctly scoped JSON Schema is not used. Probably it gets lost from `ListWithDetail → Categorization`, so that the Categorization always works on the root schema instead of the appropriately scoped one. It has to be an Angular renderer set issue as it works in general as can be seen in the React renderer set. Would you be interested in contributing a fix?

---

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [March 11, 2021, 3:47pm UTC](https://jsonforms.discourse.group/t/misunderstanding-something-about-scope/17/12 "2021-03-11T15:47:32Z")

</div>

_[henry-oconnor]_

Sure, I’ll do a little digging this weekend and see if I can figure it out. Thank you for your help!
