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

[Bug] config items with children must have an empty children: [] or the promise errors #21

Open
andrewmosby opened this issue Sep 28, 2023 · 3 comments

Comments

@andrewmosby
Copy link

Currently an entry in the config file with the following structure will cause an error (and the page will not load). Note that this is the pattern set in the README.

{
  "title": "Buttons",
  "children": [
    {
      "title": "Primary Button",
      "url": "button-primary"
    },
    {
      "title": "Secondary Button",
      "url": "button-secondary"
    }
  ]
}

This is the error produced in the console: Uncaught (in promise) TypeError: e.item.children is undefined

Currently, the workaround is to add an empty children: [] line.

{
  "title": "Buttons",
  "children": [
    {
      "title": "Primary Button",
      "url": "button-primary",
      "children": []
    },
    {
      "title": "Secondary Button",
      "url": "button-secondary",
      "children": []
    }
  ]
}

Suggested action

  • Confirm bug
  • Update README w/ current preferred structure (if creating a fix is not quick)
  • Create a fix so children: [] is not needed.
@ekfuhrmann
Copy link
Contributor

Another way of handling children might be to use the url. We can create nestings simpling through use of the url and / rather than relying on an additional children: [] prop.

It could look like this:

// BEFORE
"nav": [
    {
      "title": "Buttons",
      "children": [
        {
          "title": "Primary Button",
          "url": "button-primary",
          "children": []
        },
        {
          "title": "Secondary Button",
          "url": "button-secondary",
          "children": []
        }
      ]
    },
]
  
// AFTER
"nav": [
    {
      "title": "Primary Button",
      "url": "buttons/button-primary",
    },
    {
      "title": "Secondary Button",
      "url": "buttons/button-secondary",
    },
]

There would need to be some thought around how to parse what the title should look like for titles with a space or special character such as a hyphen, but generally speaking it'd flatten the json a bit.

@andrewmosby
Copy link
Author

@ekfuhrmann I believe this issue is "resolved" now that the json file is auto generated. Correct?

@ekfuhrmann
Copy link
Contributor

No, unfortunately we still need to pass in "children": [], it's just included as part of the auto generated JSON. That automation is also only there for our Blueprint library at the moment. Other projects would still need to generate their own JSON and include that key.

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