From bb2cb4d12dfedfdb10da8e2c7bca41207e75ef7b Mon Sep 17 00:00:00 2001 From: sam-m-m Date: Thu, 15 Jul 2021 21:43:41 -0700 Subject: [PATCH] feat #386 - Stop event propagation when clicking on cell links with an onRowClick --- src/components/Link/index.tsx | 16 +++------------- src/components/Table/types.ts | 4 ++-- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/components/Link/index.tsx b/src/components/Link/index.tsx index fb650dd7..f2ff227f 100644 --- a/src/components/Link/index.tsx +++ b/src/components/Link/index.tsx @@ -23,7 +23,7 @@ const AntDLink = Typography.Link export type LinkTargetType = '_self' | '_blank' -export interface SharedLinkProps extends CommonComponentProps { +export interface LinkProps extends CommonComponentProps { /** * Array of classes to pass to element */ @@ -40,26 +40,16 @@ export interface SharedLinkProps extends CommonComponentProps { * Whether or not the link is underlined. */ underline?: boolean -} - -interface LinkHref extends SharedLinkProps { /** * The URL the link goes to. */ - href: string + href?: string /** * Click handler. **Note**: Either an `onClick` or `href` is required. */ - onClick?: never + onClick?: React.MouseEventHandler } -interface LinkClick extends SharedLinkProps { - href?: never - onClick: () => void -} - -export type LinkProps = LinkHref | LinkClick - export const Link: FC = ({ classes = [], children, diff --git a/src/components/Table/types.ts b/src/components/Table/types.ts index 20188f4a..db0e7457 100644 --- a/src/components/Table/types.ts +++ b/src/components/Table/types.ts @@ -1,6 +1,6 @@ import { ColoredDotProps } from '../ColoredDot' +import { LinkProps } from '../Link' import { SharedIconProps } from '../Icon' -import { SharedLinkProps } from '../Link' import { TableMethods } from './utils' import { Key, ReactNode } from 'react' @@ -128,7 +128,7 @@ interface ComponentColoredDotType extends PartialComponentType { } } -interface RenderPropsLink extends Pick { +interface RenderPropsLink extends Pick { buildHref: (record?: string, data?: Record) => string isDisabled?: (record?: string, data?: Record) => boolean }