Skip to content

Commit

Permalink
Link args weren't being reapplied
Browse files Browse the repository at this point in the history
  • Loading branch information
clintandrewhall committed Jul 2, 2020
1 parent 6ea6f34 commit 5bd261f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions x-pack/plugins/canvas/public/components/link/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React, { FC, MouseEventHandler, MouseEvent } from 'react';
import React, { FC, MouseEvent } from 'react';
import PropTypes from 'prop-types';
import { EuiLink } from '@elastic/eui';
import { EuiLink, EuiLinkProps } from '@elastic/eui';

import { ComponentStrings } from '../../../i18n';

Expand All @@ -16,14 +16,15 @@ const isModifiedEvent = (ev: MouseEvent) =>
!!(ev.metaKey || ev.altKey || ev.ctrlKey || ev.shiftKey);

interface Props {
target?: string;
onClick?: MouseEventHandler;
name: string;
params: Record<string, any>;
}

export const Link: FC<Props> = ({ onClick, target, name, params, children }, { router }) => {
const navigateTo: MouseEventHandler = (ev) => {
export const Link: FC<Props & EuiLinkProps> = (
{ onClick, target, name, params, children, ...linkArgs },
{ router }
) => {
const navigateTo = (ev: MouseEvent<HTMLButtonElement, globalThis.MouseEvent>) => {
if (onClick) {
onClick(ev);
}
Expand All @@ -45,6 +46,7 @@ export const Link: FC<Props> = ({ onClick, target, name, params, children }, { r
target,
href,
onClick: navigateTo,
...linkArgs,
};

return <EuiLink {...props}>{children}</EuiLink>;
Expand All @@ -58,8 +60,6 @@ Link.contextTypes = {
};

Link.propTypes = {
target: PropTypes.string,
onClick: PropTypes.func,
name: PropTypes.string.isRequired,
params: PropTypes.object,
};

0 comments on commit 5bd261f

Please sign in to comment.