Skip to content

Commit

Permalink
[BUG-4608] Fix render custom menu item template (#4609)
Browse files Browse the repository at this point in the history
  • Loading branch information
PasBazz authored Jul 5, 2023
1 parent e9af42f commit 7d50b05
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion components/lib/contextmenu/ContextMenuSub.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { CSSTransition } from '../csstransition/CSSTransition';
import { useUpdateEffect } from '../hooks/Hooks';
import { Ripple } from '../ripple/Ripple';
import { classNames, DomHandler, IconUtils, mergeProps } from '../utils/Utils';
import { classNames, DomHandler, IconUtils, mergeProps, ObjectUtils } from '../utils/Utils';
import { AngleRightIcon } from '../icons/angleright';

export const ContextMenuSub = React.memo((props) => {
Expand Down Expand Up @@ -168,6 +168,21 @@ export const ContextMenuSub = React.memo((props) => {
</a>
);

if (item.template) {
const defaultContentOptions = {
onClick: (event) => onItemClick(event, item, index),
className: 'p-menuitem-link',
labelClassName: 'p-menuitem-text',
iconClassName,
submenuIconClassName,
element: content,
props,
active
};

content = ObjectUtils.getJSXElement(item.template, item, defaultContentOptions);
}

const menuitemProps = mergeProps(
{
id: item.id,
Expand Down

0 comments on commit 7d50b05

Please sign in to comment.