Skip to content

docs: keep anchored headings clear of the sticky section tabs - #34039

Open
MannXo wants to merge 1 commit into
angular:mainfrom
MannXo:fix/34038-docs-anchor-scroll-margin
Open

MannXo wants to merge 1 commit into
angular:mainfrom
MannXo:fix/34038-docs-anchor-scroll-margin

Conversation

@MannXo

@MannXo MannXo commented Oct 31, 2026 •

Copy link
Copy Markdown

Summary

Anchor targets on component pages scroll underneath the sticky Overview/API/Styling/Examples tab nav. This gives them a scroll-margin-top so they land below it.

Context

The tab nav (.docs-component-viewer-tabbed-content.docs-sticky-top) is position: sticky; top: 0 inside the sidenav content, which is the scroll container. Table of contents links and fragment navigation call scrollIntoView(), which aligns the target with the top of that container, so the heading ends up behind the 49px tab bar.

Measured on the dialog overview page at 1455x800, after clicking "Keyboard interaction" in the table of contents:

tab nav bottom heading top
before 105px 55.5px (covered)
after 105px 119.5px

Changes

  • docs/src/app/pages/component-viewer/component-viewer.scss: scroll-margin-top: 64px on elements with an id inside .docs-component-viewer-content. That covers headings and example viewers on every tab of a component page. Guide pages have no sticky top bar, so they are left alone.

Testing

  • pnpm stylelint: 0 problems.
  • pnpm ng-dev format changed --check <base>: all files correctly formatted.
  • pnpm ng-dev commit-message validate-range <base> HEAD: valid.
  • Compiled the file with the repo's sass. The output rule is .docs-component-viewer-content [id] { scroll-margin-top: 64px; }.
  • I did not run the Bazel docs build or bazel test //docs/.... Serving the docs locally needs a full Bazel build of the workspace, so the before and after were checked on the deployed site with the compiled rule injected through Playwright.

Screenshots

Before

image

After

image

Notes for reviewers

  • 64px is the 49px tab bar plus some breathing room. It could instead be tied to the tab height token if you prefer it derived.
  • The alternative is scroll-padding-top on .mat-sidenav-content. That would also offset guide pages, which have no sticky bar, so I scoped it to the component viewer.

Fixes #34038

The Overview/API/Styling/Examples tab nav is sticky at the top of the
scroll container, so `scrollIntoView` from the table of contents and
fragment links put the target heading underneath it. Give anchor targets
in the component viewer a `scroll-margin-top` larger than the tab nav.

Fixes angular#34038
@angular-robot angular-robot Bot added the area: docs Related to the documentation label Oct 31, 2026
@google-cla

google-cla Bot commented Oct 31, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@MannXo
MannXo marked this pull request as ready for review October 31, 2026 09:49

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: docs Related to the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs-bug(dialog): anchored links are behind document sections

1 participant