Skip to content

Commit

Permalink
Fixed #1597 - Add template property support to MenuModel API
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Sep 22, 2020
1 parent 68c0088 commit ee0531b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/splitbutton/SplitButtonItem.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import ObjectUtils from '../utils/ObjectUtils';

export class SplitButtonItem extends Component {

Expand Down Expand Up @@ -32,15 +33,18 @@ export class SplitButtonItem extends Component {
}

render() {
var className = classNames('p-menuitem-link', { 'p-disabled': this.props.menuitem.disabled });
var icon = this.props.menuitem.icon ? <span className={classNames('p-menuitem-icon', this.props.menuitem.icon)}></span> : null;
var label = <span className="p-menuitem-text">{this.props.menuitem.label}</span>;
let { disabled, icon, label, template } = this.props.menuitem;
const className = classNames('p-menuitem-link', { 'p-disabled': disabled });
const itemContent = template ? ObjectUtils.getJSXElement(template, this.props.menuitem) : null;
icon = icon && <span className={classNames('p-menuitem-icon', icon)}></span>;
label = label && <span className="p-menuitem-text">{label}</span>;

return (
<li className="p-menuitem" role="none">
<a href={this.props.menuitem.url || '#'} role="menuitem" className={className} target={this.props.menuitem.target} onClick={this.onClick}>
{icon}
{label}
{itemContent}
</a>
</li>
);
Expand Down

0 comments on commit ee0531b

Please sign in to comment.