Fixed inline links opening in new tab for external links; fixed scrolling to container if hash is provided
This commit is contained in:
committed by
fabioberger
parent
487bc1a08b
commit
1005e4962a
@@ -1,6 +1,7 @@
|
||||
import * as React from 'react';
|
||||
|
||||
import { Link } from 'ts/components/documentation/shared/link';
|
||||
import { docs } from 'ts/style/docs';
|
||||
|
||||
interface IInlineLinkProps {
|
||||
children: React.ReactNode;
|
||||
@@ -8,8 +9,10 @@ interface IInlineLinkProps {
|
||||
}
|
||||
|
||||
export const InlineLink: React.FC<IInlineLinkProps> = ({ children, href }) => {
|
||||
const to = href.replace(/#/, ''); // Remove hash from internal links so that react-scroll can find the target
|
||||
|
||||
return (
|
||||
<Link containerId="" to={href} textDecoration="underline">
|
||||
<Link containerId="" offset={-docs.headerOffset} shouldOpenInNewTab={true} to={to} textDecoration="underline">
|
||||
{children}
|
||||
</Link>
|
||||
);
|
||||
|
||||
@@ -69,10 +69,6 @@ export class Link extends React.Component<LinkProps, LinkState> {
|
||||
type = LinkType.ReactScroll;
|
||||
}
|
||||
|
||||
if (type === LinkType.ReactScroll && this.props.shouldOpenInNewTab) {
|
||||
throw new Error(`Cannot open LinkType.ReactScroll links in new tab. link.to: ${this.props.to}`);
|
||||
}
|
||||
|
||||
const styleWithDefault = {
|
||||
textDecoration: this.props.textDecoration,
|
||||
cursor: 'pointer',
|
||||
|
||||
Reference in New Issue
Block a user