Skip to content

Commit

Permalink
Fixed #2914 - Add id option to MenuItem API
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed May 22, 2022
1 parent f3a6647 commit f905d23
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion components/lib/contextmenu/ContextMenuSub.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const ContextMenuSub = React.memo((props) => {
}

return (
<li key={key} role="none" className={className} style={item.style} onMouseEnter={(event) => onItemMouseEnter(event, item)}>
<li key={key} role="none" id={item.id} className={className} style={item.style} onMouseEnter={(event) => onItemMouseEnter(event, item)}>
{content}
{submenu}
</li>
Expand Down
7 changes: 3 additions & 4 deletions components/lib/megamenu/MegaMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export const MegaMenu = React.memo(React.forwardRef((props, ref) => {
}

return (
<li key={key} className={className} style={item.style} role="none">
<li key={key} id={item.id} className={className} style={item.style} role="none">
{content}
</li>
)
Expand All @@ -249,7 +249,7 @@ export const MegaMenu = React.memo(React.forwardRef((props, ref) => {

return (
<React.Fragment key={submenu.label}>
<li className={className} style={submenu.style} role="presentation">{submenu.label}</li>
<li id={submenu.id} className={className} style={submenu.style} role="presentation">{submenu.label}</li>
{items}
</React.Fragment>
)
Expand Down Expand Up @@ -312,7 +312,7 @@ export const MegaMenu = React.memo(React.forwardRef((props, ref) => {
const panel = createCategoryPanel(category);

return (
<li key={category.label + '_' + index} className={className} style={category.style} onMouseEnter={e => onCategoryMouseEnter(e, category)} role="none">
<li key={category.label + '_' + index} id={category.id} className={className} style={category.style} onMouseEnter={e => onCategoryMouseEnter(e, category)} role="none">
<a href={category.url || '#'} className={linkClassName} target={category.target} onClick={e => onCategoryClick(e, category)} onKeyDown={e => onCategoryKeyDown(e, category)}
role="menuitem" aria-haspopup={category.items != null}>
{icon}
Expand Down Expand Up @@ -350,7 +350,6 @@ export const MegaMenu = React.memo(React.forwardRef((props, ref) => {
return null;
}


const otherProps = ObjectUtils.findDiffKeys(props, MegaMenu.defaultProps);
const className = classNames('p-megamenu p-component', {
'p-megamenu-horizontal': props.orientation === 'horizontal',
Expand Down
2 changes: 1 addition & 1 deletion components/lib/menubar/MenubarSub.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export const MenubarSub = React.memo(React.forwardRef((props, ref) => {
}

return (
<li key={key} role="none" className={className} style={item.style} onMouseEnter={(event) => onItemMouseEnter(event, item)}>
<li key={key} role="none" id={item.id} className={className} style={item.style} onMouseEnter={(event) => onItemMouseEnter(event, item)}>
{content}
{submenu}
</li>
Expand Down
1 change: 1 addition & 0 deletions components/lib/menuitem/MenuItem.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface MenuItemOptions {
type MenuItemTemplateType = React.ReactNode | ((item: MenuItem, options: MenuItemOptions) => React.ReactNode);

export interface MenuItem {
id?: string;
label?: string;
icon?: any;
url?: string;
Expand Down
2 changes: 1 addition & 1 deletion components/lib/panelmenu/PanelMenuSub.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const PanelMenuSub = React.memo((props) => {
}

return (
<li key={key} className={className} style={item.style} role="none">
<li key={key} id={item.id} className={className} style={item.style} role="none">
{content}
{submenu}
</li>
Expand Down
2 changes: 1 addition & 1 deletion components/lib/slidemenu/SlideMenuSub.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const SlideMenuSub = React.memo((props) => {
}

return (
<li key={key} className={className} style={item.style}>
<li key={key} id={item.id} className={className} style={item.style}>
{content}
{submenu}
</li>
Expand Down
2 changes: 1 addition & 1 deletion components/lib/steps/Steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const Steps = React.memo(React.forwardRef((props, ref) => {
}

return (
<li key={key} className={className} style={item.style} role="tab" aria-selected={active} aria-expanded={active}>
<li key={key} id={item.id} className={className} style={item.style} role="tab" aria-selected={active} aria-expanded={active}>
{content}
</li>
)
Expand Down
4 changes: 2 additions & 2 deletions components/lib/tieredmenu/TieredMenuSub.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export const TieredMenuSub = React.memo((props) => {
}

const createMenuItem = (item, index) => {
const { className: _className, style, disabled, icon: _icon, label: _label, items, target, url, template } = item;
const { id, className: _className, style, disabled, icon: _icon, label: _label, items, target, url, template } = item;
const key = _label + '_' + index;
const active = activeItemState === item;
const className = classNames('p-menuitem', { 'p-menuitem-active': active }, _className);
Expand Down Expand Up @@ -204,7 +204,7 @@ export const TieredMenuSub = React.memo((props) => {
}

return (
<li key={key} className={className} style={style} onMouseEnter={(event) => onItemMouseEnter(event, item)} role="none">
<li key={key} id={item} className={className} style={style} onMouseEnter={(event) => onItemMouseEnter(event, item)} role="none">
{content}
{submenu}
</li>
Expand Down

0 comments on commit f905d23

Please sign in to comment.