primefaces / primereact

The Most Complete React UI Component Library
https://primereact.org
MIT License
6.88k stars 1.04k forks source link

PanelMenu: Cannot change icon when expanding or compressing submenu #7026

Closed franmc01 closed 2 months ago

franmc01 commented 3 months ago

Describe the bug

image Generally when I use the default menu panel the options are presented like this, in itself there is nothing wrong but it happens that I have a use case where I use the template in each menu item and I want the arrows but not in item: MenuItem , options: MenuItemOptions can be changed because it is not exposed.

The closest thing is the submenuIcon property but it is not for the arrow, the closest option I found was to use item.expanded type like this

 const itemRenderer = (item: MenuItem, options: MenuItemOptions) => {
 console.log({ item, options });
 return (
 <a
 className="flex align-items-center p-2 cursor-pointer"
 onClick={options.onClick}
 >
 <span>
 <span className={`${item.icon}`} />
 <span className={`mx-2 ${item.items && "font-semibold"}`}>
 {item.label}
 </span>
 </span>
 <span className={`${item.expanded ? 'my-icon': '"other-icon'}`} />
 </a>
 );
 };

but in itself it does not work because its change of state is not repeated; then or always is false. I tried the PT property but it didn't work either.

Reproducer

No response

System Information

X

Steps to reproduce the behavior

No response

Expected behavior

I would expect that the update is visible or, failing that, that the api returns or exposes two properties to be able to use or play when using the template

melloware commented 3 months ago

I think PanelMenu needs ExpandIcon and CollapseIcon props similar to Accordion: https://primereact.org/accordion/#api.Accordion.props.collapseIcon

franmc01 commented 3 months ago

Exactly @melloware

franmc01 commented 3 months ago

Hey @melloware ,

I finally got the courage to make some updates and would love your feedback on this PR.

Thanks!