From 055763cceb9951b038b07488ddc7ae35210f1efe Mon Sep 17 00:00:00 2001
From: Fabio Berger <me@fabioberger.com>
Date: Fri, 5 Oct 2018 11:13:33 +0100
Subject: Fix bug where wiki links in dev dropdown weren't working when on the
 wiki

---
 .../ts/components/dropdowns/developers_drop_down.tsx     | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

(limited to 'packages/website/ts/components/dropdowns/developers_drop_down.tsx')

diff --git a/packages/website/ts/components/dropdowns/developers_drop_down.tsx b/packages/website/ts/components/dropdowns/developers_drop_down.tsx
index 6133c8b4d..ac1d82c75 100644
--- a/packages/website/ts/components/dropdowns/developers_drop_down.tsx
+++ b/packages/website/ts/components/dropdowns/developers_drop_down.tsx
@@ -64,6 +64,7 @@ const usefulLinksToLinkInfo: ALink[] = [
 ];
 
 interface DevelopersDropDownProps {
+    location: Location;
     translate: Translate;
     menuItemStyles: React.CSSProperties;
     menuIconStyle: React.CSSProperties;
@@ -165,17 +166,20 @@ export class DevelopersDropDown extends React.Component<DevelopersDropDownProps,
         const numLinks = links.length;
         let i = 0;
         const renderLinks = _.map(links, (link: ALink) => {
+            const isWikiLink = _.startsWith(link.to, WebsitePaths.Wiki) && _.includes(link.to, '#');
+            const isOnWiki = this.props.location.pathname === WebsitePaths.Wiki;
+            let to = link.to;
+            let type = link.type;
+            if (isWikiLink && isOnWiki) {
+                to = `${link.to.split('#')[1]}`;
+                type = LinkType.ReactScroll;
+            }
             i++;
             const isLast = i === numLinks;
             const linkText = this.props.translate.get(link.title as Key, Deco.Cap);
             return (
                 <div className={`pr1 pt1 ${!isLast && 'pb1'}`} key={`dev-dropdown-link-${link.title}`}>
-                    <Link
-                        to={link.to}
-                        type={link.type}
-                        shouldOpenInNewTab={!!link.shouldOpenInNewTab}
-                        style={linkStyle}
-                    >
+                    <Link to={to} type={type} shouldOpenInNewTab={!!link.shouldOpenInNewTab} style={linkStyle}>
                         {linkText}
                     </Link>
                 </div>
-- 
cgit v1.2.3

