Skip to content

Commit

Permalink
feat #386 - Stop event propagation when clicking on cell links with a…
Browse files Browse the repository at this point in the history
…n onRowClick
  • Loading branch information
sam-dassana committed Jul 17, 2021
1 parent 5769738 commit bb2cb4d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
16 changes: 3 additions & 13 deletions src/components/Link/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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<HTMLAnchorElement>
}

interface LinkClick extends SharedLinkProps {
href?: never
onClick: () => void
}

export type LinkProps = LinkHref | LinkClick

export const Link: FC<LinkProps> = ({
classes = [],
children,
Expand Down
4 changes: 2 additions & 2 deletions src/components/Table/types.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -128,7 +128,7 @@ interface ComponentColoredDotType extends PartialComponentType {
}
}

interface RenderPropsLink extends Pick<SharedLinkProps, 'target'> {
interface RenderPropsLink extends Pick<LinkProps, 'target'> {
buildHref: (record?: string, data?: Record<string, any>) => string
isDisabled?: (record?: string, data?: Record<string, any>) => boolean
}
Expand Down

0 comments on commit bb2cb4d

Please sign in to comment.