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
- Enable the core Navigation module, enable `anchor_scroll`.
- As a logged-in user, open a page with in-page anchor links and click one.
- 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
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
Comment #3
pivica commentedComment #4
pivica commented