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

MegaMenu: items must be MenuItem[][]. MenuItem[] does not work #6415

Closed
pburrows opened this issue Apr 18, 2024 · 0 comments · Fixed by #6416
Closed

MegaMenu: items must be MenuItem[][]. MenuItem[] does not work #6415

pburrows opened this issue Apr 18, 2024 · 0 comments · Fixed by #6416
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@pburrows
Copy link

Describe the bug

The error "Uncaught TypeError: items.forEach is not a function" is displayed in MegaMenu when the items property is an array of MenuItem objects.

If you make it an array of arrays, it works as expected.

The documentation clearly shows that items can be either an array Or an array of arrays:
https://primereact.org/megamenu/#api.MenuItem.props.items

Reproducer

https://stackblitz.com/edit/npktaj?file=src%2FApp.jsx

PrimeReact version

latest

React version

17.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

set items property of a megamenu item to be a single array, such as:

 {
      label: 'Furniture',
      icon: 'pi pi-box',
      items: [
        { label: 'Accessories' },
        { label: 'Armchair' },
        { label: 'Coffee Table' },
        { label: 'Couch' },
        { label: 'TV Stand' },
      ],
    },

Expected behavior

The single array of menuitems should render

@pburrows pburrows added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Apr 18, 2024
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Apr 18, 2024
@melloware melloware added this to the 10.6.4 milestone Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants