aleph icon indicating copy to clipboard operation
aleph copied to clipboard

Menu links on "About" pages should use correct link markup

Open tillprochaska opened this issue 2 years ago • 3 comments

Currently, navigation after clicking on links in the pages sidebar menu is handled by intercepting click events. As the menu items aren’t rendered as a tags with an href attribute, native browser features (e.g. opening a link in a new tab) won’t work for that reason. Also, the links cannot receive keyboard focus.

Screenshot 2022-06-07 at 14 27 35

This has been difficult to fix with previous Blueprint and React Router version, but has been solved in the meantime (https://github.com/palantir/blueprint/pull/3061), so it should be easy to fix now.

tillprochaska avatar Jun 07 '22 12:06 tillprochaska

Turns out there is still no solution to this that doesn’t require ugly workarounds. While the following renders correctly, it leads to incorrectly nested HTML markup:

<Link to={getPageLink(menuPage)}>
  <MenuItem tagName="div" ... />
</Link>

Renders as:

<ul class="bp3-menu">
  <a href="/pages/...">
    <li>
      ...
    </li>
  </a>
</ul>

tillprochaska avatar Jun 08 '22 10:06 tillprochaska

For future reference: The way to go with React Router v6 is to use the useLinkClickHandler and useHref hooks.

tillprochaska avatar Jun 09 '22 10:06 tillprochaska

Other places that currently use workarounds:

  • https://github.com/alephdata/aleph/blob/main/ui/src/components/Navbar/Navbar.jsx#L129-L146
  • https://github.com/alephdata/aleph/blob/main/ui/src/components/Dashboard/Dashboard.jsx#L94-L182

tillprochaska avatar Jun 09 '22 10:06 tillprochaska

This has been fixed in the meantime.

tillprochaska avatar Feb 15 '23 10:02 tillprochaska