From fdaf9f0bfc24a93933fb492d727d970d8c82d8ee Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Sat, 3 Mar 2018 05:36:26 +0100 Subject: Fix comment and use named variable in conditional --- packages/website/ts/pages/shared/markdown_link_block.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'packages') diff --git a/packages/website/ts/pages/shared/markdown_link_block.tsx b/packages/website/ts/pages/shared/markdown_link_block.tsx index ed78e4e53..e4553c87f 100644 --- a/packages/website/ts/pages/shared/markdown_link_block.tsx +++ b/packages/website/ts/pages/shared/markdown_link_block.tsx @@ -10,13 +10,14 @@ interface MarkdownLinkBlockProps { interface MarkdownLinkBlockState {} export class MarkdownLinkBlock extends React.Component { - // Re-rendering a linkBlock causes any use selection to become de-selected making the link unclickable. + // Re-rendering a linkBlock causes it to remain unclickable. // We therefore noop re-renders on this component if it's props haven't changed. public shouldComponentUpdate(nextProps: MarkdownLinkBlockProps, nextState: MarkdownLinkBlockState) { return nextProps.href !== this.props.href; } public render() { const href = this.props.href; + const isLinkToSection = _.startsWith(href, '#'); // If protocol is http or https, we can open in a new tab, otherwise don't for security reasons if (_.startsWith(href, 'http') || _.startsWith(href, 'https')) { return ( @@ -24,7 +25,7 @@ export class MarkdownLinkBlock extends React.Component ); - } else if (_.startsWith(href, '#')) { + } else if (isLinkToSection) { return (