Skip to content

Commit

Permalink
Deduplicate buttonInner code.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed Jun 7, 2018
1 parent e0a0d1a commit 53063a6
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/components/context_menu/context_menu_item.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ export class EuiContextMenuItem extends Component {
'euiContextMenuItem-isDisabled': disabled,
});

const buttonInner = (
<span className="euiContextMenu__itemLayout">
{iconInstance}
<span className="euiContextMenuItem__text">
{children}
</span>
{arrow}
</span>
);

let button;
// <a> elements don't respect the `disabled` attribute. So if we're disabled, we'll just pretend
// this is a button and piggyback off its disabled styles.
Expand All @@ -113,13 +123,7 @@ export class EuiContextMenuItem extends Component {
ref={buttonRef}
{...rest}
>
<span className="euiContextMenu__itemLayout">
{iconInstance}
<span className="euiContextMenuItem__text">
{children}
</span>
{arrow}
</span>
{buttonInner}
</a>
);
} else {
Expand All @@ -131,13 +135,7 @@ export class EuiContextMenuItem extends Component {
ref={buttonRef}
{...rest}
>
<span className="euiContextMenu__itemLayout">
{iconInstance}
<span className="euiContextMenuItem__text">
{children}
</span>
{arrow}
</span>
{buttonInner}
</button>
);
}
Expand Down

0 comments on commit 53063a6

Please sign in to comment.