Problem/Motivation

`anchor_scroll.fixed_elements` only lists the classic Toolbar selectors (`.toolbar-bar`, `.toolbar-tray.is-active.toolbar-tray-horizontal`). Sites using the new core Navigation module have a `.top-bar` instead, which is not accounted for - so for logged-in users anchor/TOC links scroll the target underneath the fixed top bar.

Just adding `.top-bar` is not enough: it is `position: fixed` only at `≥64rem` and sits in normal flow below that, while `getFixedElementsOffset()` reads each element's bounding rect unconditionally - so on smaller viewports it would feed a wrong offset.

Steps to reproduce

  1. Enable the core Navigation module, enable `anchor_scroll`.
  2. As a logged-in user, open a page with in-page anchor links and click one.
  3. The target lands behind the fixed top bar.

Proposed resolution

  • In `getFixedElementsOffset()`, only count an element when its computed position is fixed or sticky (skips the Navigation top bar where it is not pinned, e.g. below 64rem).
  • Add `.top-bar` to the default `fixed_elements`, keeping the classic Toolbar selectors for backward compatibility.
  • Add an idempotent hook_post_update_N() that appends .top-bar to existing sites' fixed_elements.

Remaining tasks

Review and commit the MR.

Issue fork bs_lib-3606602

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pivica created an issue. See original summary.

pivica’s picture

Status: Active » Needs review
pivica’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • pivica committed 9598491e on 2.0.x
    fix: #3606602 Anchor scroll does not account for the new core Navigation...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.