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

oneOf - indexOfFittingSchema doesn't match the correct index. #2407

Open
cihad opened this issue Dec 13, 2024 · 0 comments
Open

oneOf - indexOfFittingSchema doesn't match the correct index. #2407

cihad opened this issue Dec 13, 2024 · 0 comments

Comments

@cihad
Copy link

cihad commented Dec 13, 2024

Describe the bug

const schema = {
  type: "object",
  properties: {
    provider: {
      oneOf: [
        {
          type: "object",
          title: "Google",
          properties: {
            type: { const: "Google" }
          }
        },
        {
          type: "object",
          title: "Github",
          properties: {
            type: { const: "Github" },
            accessKey: { type: "string" }
          }
        }, 
      ]
    }
  }
}

const data = {
  provider: {
    type: "Github"
  }
}

In this case, the oneOf renderer tab should come with the Github tab selected, but it comes with the Google tab selected.

Expected behavior

const values are considered for the selected tab

Steps to reproduce the issue

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Screenshots

No response

Which Version of JSON Forms are you using?

v3.4.1

Package

Core

Additional context

The problem is caused by the indexOfFittingSchema prop giving the wrong value. This is also caused by excluding const errors with structuralKeywords in the dataIsValid function.

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

1 participant