Menu auto-closes on MenuItem.template clicks even when interacting with custom content
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 50/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- react
- Domain
- frontend
Research direction
Start at the Menu popup item click handling and reproduce the issue with the provided MenuItem.template and Checkbox example. Trace how clicks from template content are treated, then verify that interacting with template elements keeps the menu open while ordinary menu item behavior remains unchanged.
Written by the indexing model from the issue text.
Description
Title: Menu auto-closes on MenuItem.template clicks
Description:
When using a Menu with MenuItem.template, any click inside the template (e.g., a checkbox) closes the menu immediately. The menu should stay open while interacting with elements inside the template.
Minimal Reproducible Example:
import React, { useState, useRef } from "react";
import { Menu } from "primereact/menu";
import { Button } from "primereact/button";
import { Checkbox } from "primereact/checkbox";
export default function ColumnMenuExample() {
const menuRef = useRef<Menu>(null);
const [checked, setChecked] = useState(false);
const items = [
{
template: () => (
<div onClick={(e) => e.stopPropagation()}>
<Checkbox checked={checked} onChange={() => setChecked(!checked)} />
Column 1
</div>
),
},
];
return (
<div>
<Button label="Toggle Menu" onClick={(e) => menuRef.current?.toggle(e)} />
<Menu ref={menuRef} popup model={items} />
</div>
);
}
Steps to Reproduce:
- Click “Toggle Menu”.
- Click the checkbox inside the menu.
Actual behavior: Menu closes after checkbox click.
Expected behavior: Menu should stay open while interacting with template elements.
Workaround: Adding onClick={(e) => e.stopPropagation()} on the template prevents auto-close.
Environment:
"primereact": "^10.9.7",
"react": "19.2.1",
- Dominant language
- CSS
- Stars
- 8.3k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from primefaces/primereact
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
primefaces/primereact#8552 ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
primefaces/primereact#8550 ·
-
Row checkbox selection tick is invisible in Landing Page Theme sectionPossibly taken @Prakash1185 claimed this 173 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
primefaces/primereact#8545 ·
-
Dependency conflict between jspdf v4 and jspdf-autotable during npm installPossibly taken @Kamran92 claimed this 187 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
primefaces/primereact#8537 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
primefaces/primereact#8551 ·
All issues in primefaces/primereact
Similar issues
-
[BUG]: Shared links drop the configured basePath on GitHub PagesPossibly taken @anshulchikhale30-p claimed this today. Openbug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
StabilityNexus/IdentityTokens-EVM-Frontend#182 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 Under an hour Newbie friendliness 82/100
Leonxlnx/taste-skill#216 ·
Maintainers usually reply within 1 day
-
area: ui Bug Payload OSS
Difficulty 1/5 Under an hour Newbie friendliness 88/100
payloadcms/payload#19839 ·
Maintainers usually reply within 1 day
-
BoxShadow.lerp returns the wrong blur style at t = 0 or t = 1Possibly taken @ArtemChikolaev claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day