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

PanelMenu: command of MenuItem without child cannot be triggered #5255

Closed
matchman72 opened this issue Nov 7, 2023 · 3 comments · Fixed by #5259
Closed

PanelMenu: command of MenuItem without child cannot be triggered #5255

matchman72 opened this issue Nov 7, 2023 · 3 comments · Fixed by #5259
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@matchman72
Copy link

matchman72 commented Nov 7, 2023

Describe the bug

Changes introduced in a421b68, command is no longer triggered when MenuItem has no child

Reproducer

No response

PrimeReact version

10.0.9

React version

17.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

import { PanelMenu } from 'primereact/panelmenu';

function App() {
  const menuItems = [
      {
          label: "Group1",
          items: [{
              label: "Item 1",
              command: () => {
                    alert("Test Me alert Item 1");
              }
          },
          {
              label: "Item 2",
              command: () => {
                    alert("Test Me alert Item 2");
              }
          }
          ]
      },
      {
          label: "Test Me alert!",
          command: () => {
              alert("Test Me alert");
          }
      }
  ];
  
  return (
    <>
        <PanelMenu model={menuItems} />
    </>
  );
}

export default App;
  • Click on bottom "Test Me alert!" would trigger the func defined in command

image

Expected behavior

  • Click on bottom item "Test Me alert!"
  • With "primereact": "10.0.2", the event is triggered
  • With "primereact": "10.0.9", the event cannot be triggered (as item.items returns false)
  • If I define a dummy list into last menu item, the event is triggered (as item.items returns true) in "10.0.9". However PanelMenu treats the item as expandable item and leave an empty space after event is triggered
      {
          label: "Test Me alert!",
          items: [{}],
          command: () => {
              alert("Test Me alert");
          }
      }

image

@matchman72 matchman72 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Nov 7, 2023
@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 Nov 7, 2023
@melloware melloware added this to the 10.0.10 milestone Nov 7, 2023
@melloware
Copy link
Member

@gucal looks like you introduced this issue with #5190

@gucal
Copy link
Contributor

gucal commented Nov 7, 2023

Good catch. Thanks for the report. i will take care of it as soon as possible.

@Simsopheap
Copy link

Thank you so much! ❇️

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.

5 participants