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

Overly deep nesting of objects, there is an error in assigning values to formData. #4334

Closed
4 tasks done
amazingywk opened this issue Oct 10, 2024 · 7 comments · Fixed by #4356
Closed
4 tasks done

Comments

@amazingywk
Copy link

amazingywk commented Oct 10, 2024

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

In this playground example,When we change the value of dropdown A, B and C do not appear in formData. We suspect that it is a bug caused by overly deep nesting of objects.

{
  "type": "object",
  "properties": {
    "abc": {
      "type": "object",
      "properties": {
        "a": {
          "type": "string",
          "enum": [
            "aaa",
            "bbb"
          ],
          "enumNames": [
            "test1",
            "test2"
          ],
          "default": "aaa"
        }
      },
      "dependencies": {
        "a": {
          "oneOf": [
            {
              "properties": {
                "a": {
                  "enum": [
                    "bbb"
                  ]
                },
                "b": {
                  "type": "object",
                  "properties": {
                    "c": {
                      "type": "string",
                      "enum": [
                        "withBefore"
                      ],
                      "enumNames": [
                        "111"
                      ],
                      "default": "withBefore"
                    }
                  }
                }
              }
            },
            {
              "properties": {
                "a": {
                  "enum": [
                    "aaa"
                  ]
                }
              }
            }
          ]
        }
      }
    }
  }
}

Expected Behavior

No response

Steps To Reproduce

No response

Environment

- OS:
- Node:
- npm:

Anything else?

No response

@amazingywk amazingywk added bug needs triage Initial label given, to be assigned correct labels and assigned labels Oct 10, 2024
@amazingywk amazingywk changed the title For fields of type string with enums options, when setting the default value, there is an error in assigning values to formData. Overly deep nesting of objects, there is an error in assigning values to formData. Oct 10, 2024
@heath-freenome heath-freenome added awaiting response and removed needs triage Initial label given, to be assigned correct labels and assigned labels Oct 11, 2024
@heath-freenome
Copy link
Member

@amazingywk I added a shared link to your description above with your example. When I try it out it seems to be working fine. Can you provide a screen recording of what you believe isn't working?

@amazingywk
Copy link
Author

@amazingywk I added a shared link to your description above with your example. When I try it out it seems to be working fine. Can you provide a screen recording of what you believe isn't working?

imagewhen you choose "a" into "test2", the right place show "b" and "c", but in the formData, "b" and "c" did not appear and were not assigned values. This can also lead to other problems: if I set another variable "d" that depends on "b" and "c", then this "d" may not even appear on the right side.

@heath-freenome
Copy link
Member

@amazingywk The fact that 111 is should up is the result of the UI rendering and the enum only having a single value with a default. Any yet when I tried a playground with the dependencies removed I do see the default value showing up. So it looks like you have found a bug in how we process dependencies while defaulting.

@heath-freenome
Copy link
Member

heath-freenome commented Oct 25, 2024

@abdalla-rko I am not sure whether your fix for #4282 covered this case. Do you have time to investigate?

@amazingywk
Copy link
Author

@abdalla-rko I am not sure whether your fix for #4282 covered this case. Do you have time to investigate?

The version in my project is 1.8.1 and there is no such problem. But this is not the key to the problem. Because I reproduced this problem on the playground. There is no problem locally. However, local debugging is not as efficient as the playground. Perhaps you haven't updated the playground version? If it is the latest version, then I understand that there should be this problem in your latest version.

@abdalla-rko
Copy link
Contributor

Hi @amazingywk, not sure what you mean by version 1.8.1 and for what it is. But I could reproduce the issue easily on the playground and just did a pr for the fix. It should be fixed once it's merged.

@amazingywk
Copy link
Author

你好@amazingywk,不确定你说的 1.8.1 版本是什么意思,也不知道它是什么。但我可以在操场上轻松重现这个问题,只需为修复做一个 pr 即可。合并后应该会修复。

thank you!

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