Skip to content

Default value for const #2399

Open
Open
@cihad

Description

@cihad

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions