Fixed button not sending to external link

Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
Florian Bouillon 2021-09-05 14:02:46 +02:00
parent a704e43fbf
commit 1d0108ac80
Signed by: Florian Bouillon
GPG Key ID: 50BD648F12C86AB6
3 changed files with 75 additions and 68 deletions

View File

@ -25,3 +25,10 @@ WithImg.args = {
href: '/pouet', href: '/pouet',
block: true block: true
} }
export const ExternalLinkButton = (args: any) => <Component {...args}>Button</Component>
ExternalLinkButton.args = {
nomargintop: true,
href: 'https://example.com',
block: true
}

View File

@ -1,5 +1,5 @@
import React, { FC } from 'react' import React, { FC } from 'react'
import Link from 'next/link' import Link from '../Link'
import { ColorType, IconProps } from '../interfaces' import { ColorType, IconProps } from '../interfaces'
import { buildClassName } from '../Util' import { buildClassName } from '../Util'
import Image from '../Image' import Image from '../Image'
@ -57,8 +57,8 @@ export default class Button extends React.Component<Props> {
if (this.props.href) { if (this.props.href) {
return ( return (
<Link href={this.props.href} as={this.props.as}> <Link linkProps={{onClick: this.props.onClick}} hideIcon noStyle href={this.props.href} className={buildClassName([classes], [css.disabled, this.props.disabled])}>
<a onClick={this.props.onClick} className={buildClassName([classes], [css.disabled, this.props.disabled])}>{inner}</a> {inner}
</Link> </Link>
) )
} }

View File

@ -30,7 +30,7 @@ export default class Link extends React.Component<Props> {
public render() { public render() {
const isExternal = this.props.href.startsWith('http') const isExternal = this.props.href.startsWith('http')
const externalProps = this.props.external ? { const externalProps = this.props.external ?? isExternal ? {
rel: 'noreferrer nofollow', rel: 'noreferrer nofollow',
target: '_blank' target: '_blank'
} : {} } : {}