Skip to content

Link Objects visible in Volto Menu with anchor as target do not scroll to position of the anchor #692

@acsr

Description

@acsr

UPDATED Now tested in plain Volto / Pastanaga! Same in plain volto in the standard main navigation
needs to be recreated in volto repo.

Issue: In the main Navigation:

  • Link Object with links to anchors are shown in the menu with their title
  • They show their target url in the browser status bar
  • Clicks are not resulting in scroll to anchor on same page or others.
  • If you are logged in, the Link Object opens. From there clicking the link results in scrolling to the anchor at the target url.

Same in mobile navigation!

We stumbled over this during work o the Plone Tagung 2025 website at https://tagung.plone.de and was elaborated and verified now deeper with latest VLT.

verified with https://demo.plone.org
Volto 18.27.3
Plone 6.1.3
@kitconcept/volto-light-theme 7.2.0 (Fat Menu activated)

Locally tested with 7.3.1 (with and without Fat Menu activated)

Steps to reproduce

Plone 6.1.x with Volto 18 and VLT from 6.0.1alpha21 to 7.3.1

  • Add an anchor on the middle of the root page (see below, use the HTML-Block or Text-Block with an H2 or h3.
  • Create a Link Object in the site root (or LRF) in Volto using VLT
  • in the target link field enter a full path to an anchor on the LRF page. eg. /#about or /de#about on an intl site
  • Make sure you have not activates the Hide from Navigation option

Result

  • The link shows up in the navigation

We test the link in public view (not logged in)

  • On hover on desktop the proper absolute url is shown
  • On click on the same page -> The browser stays on the page, displays the anchor url but stays where you are
  • On click on other page -> The browser jumps to the page, displays the anchor url but stays at the top or stays where you are vertically.
  • If you enter the displayed url in the browser manually and hit return, the browser jumps to that anchor on the same page or others.

Troubleshooting

  • Add the Link Object as target to the new Header Actions of VLT 6.2.0+ -> link to the anchor works and jumps to the anchor.
  • Add the rendered link code manually to the rendered html using devtools -> link works and jumps to the anchor.
  • Use an id of a slot of a volto-accordion-block as target in the link object, the browser reloads the page even when on the page (not nice) and opens the target.
  • No obvious events in the console pointing to javascript failures

How to create Anchors in Volto

  • Slug based anchors for headings are only created by slate for the text-blocks containing H2 and H3, not for the others or the Heading block.
  • other default blocks for VLT except the volto-accordion-block generate no unique IDs.
  • eeacms/volto-anchors tested – does not change this at all.
  • You can use a plain HTML block with this code: <a id="about" style="scroll-margin-top: 4rem;"></a> (scroll-margin-top can adjust the offset of the target if you use sticky stuff at the top.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions