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

Closed
cihad opened this issue Dec 13, 2024 · 1 comment
Closed

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

cihad opened this issue Dec 13, 2024 · 1 comment

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.

@lucas-koehler
Copy link
Contributor

lucas-koehler commented Jan 10, 2025

Hi @cihad , thanks for the report!
This should be solved when #2371 is implemented where the index selection is planned to consider properties like id/type/kind that have a const value defined.
Thus, I'll close this issue as a duplicate for now. Feel free to reopen if you disagree!

@lucas-koehler lucas-koehler closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2025
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