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

Default value for const #2399

Open
cihad opened this issue Nov 29, 2024 · 1 comment
Open

Default value for const #2399

cihad opened this issue Nov 29, 2024 · 1 comment
Labels

Comments

@cihad
Copy link

cihad commented Nov 29, 2024

Describe the bug

If we have:

export const sampleSchema = {
  type: "object",
  title: "OAuth Providers",
  oneOf: [
    {
      properties: {
        type: { const: "Google" },
        secretKey: { type: "string" },
      },
    },
    {
      properties: {
        type: { const: "Github" },
        callbackUrl: { type: "string" },
      },
    },
  ],
};

When switching between tabs, the createDefaultValue function fills the data with default values, but the type property is not included in data because it does not have an default value.

Expected behavior

createDefaultValue function should consider only const values and not default values when switching between tabs in oneOf tab selector.

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

No response

@lucas-koehler
Copy link
Contributor

Hi @cihad Thanks for the report! Also see this discussion for more information: https://jsonforms.discourse.group/t/custom-renderer-for-oneof-inside-array-items-react/2473/2

createDefaultValue function should consider only const values and not default values when switching between tabs in oneOf tab selector.

Is there a reason why default values explicitly should not be created from your point of view?

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

No branches or pull requests

2 participants