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

Enum wont be selected on load if it not the first element #1558

Closed
mochouinard opened this issue Apr 30, 2024 · 2 comments
Closed

Enum wont be selected on load if it not the first element #1558

mochouinard opened this issue Apr 30, 2024 · 2 comments
Assignees

Comments

@mochouinard
Copy link

General information

  • json-editor version: latest 2.15.0

Expected behavior

When you load a JSON with an enum, the correct item is selected in the drop box.

Actual behavior

In version 2.15.0 (2.14.1 doesn't have this problem), if you load a json with enum, if it not the first element that is selected in the json, the dropdown won't have anything selected.

Steps to reproduce the behavior

Simple schema item below and load { "example": "suzanne" } The drop down won't have anything selected in 2.15.0.

{
  "title": "json schema example",
  "type": "object",
  "properties": {
    "example": {
      "type": "string",
      "description": "This is an example schema.",
        "enum": [
            "louise",
            "suzanne",
            "heather"
          ],
          "options": {
            "enum_titles": [
              "FR - Louise",
              "FR - Suzanne",
              "EN - Heather"
            ]
          }

    }
  }
}
@waltzofpearls
Copy link

waltzofpearls commented May 1, 2024

I encountered the same issue when using enum, enum_titles and choices editor in 2.15.0. The json-editor always has the first item in the list selected. It works fine after I switched back to 2.14.1.

{
  'country': {
    'title': 'Countries',
    'type': 'array',
    'format': 'table',
    'items': {
      'type': 'string',
      'title': 'Country',
      'format': 'choices',
      'enum': Object.keys(countries),
      'options': { enum_titles: Object.values(countries) }
    }
  }
}

@germanbisurgi
Copy link
Collaborator

fixed in #1565

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

No branches or pull requests

4 participants