Skip to content

Commit

Permalink
Using tagName JSX variable for MenuItem (#3061)
Browse files Browse the repository at this point in the history
* Using tagName JSX variable for MenuItem

* Fixed minnor default issues as per the requests on PR
  • Loading branch information
barkermn01 authored and giladgray committed Nov 15, 2018
1 parent 110deb8 commit aae9532
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/core/src/components/menu/menuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ export interface IMenuItemProps extends IActionProps, ILinkProps {
* @default true
*/
shouldDismissPopover?: boolean;

/**
* Name of the HTML tag that wraps the MenuItem.
* @default "a"
*/
tagName?: keyof JSX.IntrinsicElements;
}

export class MenuItem extends React.PureComponent<IMenuItemProps & React.AnchorHTMLAttributes<HTMLAnchorElement>> {
Expand All @@ -95,6 +101,7 @@ export class MenuItem extends React.PureComponent<IMenuItemProps & React.AnchorH
popoverProps,
shouldDismissPopover,
text,
tagName: TagName = "a",
...htmlProps
} = this.props;
const hasSubmenu = children != null;
Expand All @@ -114,14 +121,14 @@ export class MenuItem extends React.PureComponent<IMenuItemProps & React.AnchorH
);

const target = (
<a {...htmlProps} {...(disabled ? DISABLED_PROPS : {})} className={anchorClasses}>
<TagName {...htmlProps} {...(disabled ? DISABLED_PROPS : {})} className={anchorClasses}>
<Icon icon={icon} />
<Text className={Classes.FILL} ellipsize={!multiline}>
{text}
</Text>
{this.maybeRenderLabel(labelElement)}
{hasSubmenu && <Icon icon="caret-right" />}
</a>
</TagName>
);

const liClasses = classNames({ [Classes.MENU_SUBMENU]: hasSubmenu });
Expand Down

1 comment on commit aae9532

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using tagName JSX variable for MenuItem (#3061)

Previews: documentation | landing | table

Please sign in to comment.