Dismiss Notice

Register now to be one of the first members of this SharePoint Community! Click here it just takes seconds!

Dismiss Notice
Welcome Guest from Country Flag

SPFX Webpart sidebar sub-navigation with React Router

Discussion in 'SharePoint Blogs' started by /u/icantevenply22, Oct 12, 2019.

Thread Status:
Not open for further replies.
  1. /u/icantevenply22

    /u/icantevenply22 Guest

    Blog Posts:
    0
    Hi,has any somebody used React Router with the default left sidebar navigation from sharepoint online, especially with sub-menu items?Currently the router is not registering/receiving changes from the left navigation when we click different links on the same webpart. I have a project that did work fine just a couple of weeks ago, but currently the links don't work.

    Here's a (try for) detailed explanation:We have a normal SP Online / SPFX Webpart, which will host, let's say, "forum groups" (eg. something like reddit) and each one of these "forum groups". In the left navigation we have this:

    *Facebook (different webpart)*Reddit- sharepoint- programmingetc..

    From the ract router we have the HashRouter and each one of these has links something like: reddit.aspfx#/sharepoint/home/post-134 .To save the Router string in the sub-menu links I add a query param infront the router like this: reddit.aspfx ?nav-sharepoint #/sharepoint/home/post-134The query is used so we can save the React Router part of the url to the link, because SP will delete it other wise.

    Inside each sub-forum the links are workign, we have history items ,change detect, etc. But when you are browsing the "sharepoint forum" and decide to click the left menu link for the main Reddit link or some of the other sub-link... nothing happens. If you click one more time I get this error in the console: Error: Failed to find anchor to scroll

    Has anybody tried this or even fixed it? There are workarounds like adding some links/buttons inside the webpart to navigate through the sub-parts, but I'm looking for fixing this navigation, rather than adding more code and functionalities atm.

    Btw, I found this: https://techcommunity.microsoft.com...rePoint-Roadmap-Pitstop-July-2019/ba-p/776272 where they've listed: On-page anchors. SharePoint will support anchor links, which allow readers to jump to a specific part of the page.Is my feeling correct and this is the reason for this behavior/bug? And if so, does this really means that we can't use React Router in spfx?

    Thanks in advance for any help, feedback and ideas!

    submitted by /u/icantevenply22
    [link] [comments]

    Continue reading...
     
Thread Status:
Not open for further replies.

Share This Page

LiveZilla Live Chat Software