Skip to content

Fix wrong On-this-page entry on anchor jumps, and tables squeezed by a code block - #443

Open
JakeSCahill wants to merge 2 commits into
mainfrom
jake/toc-anchor-highlight-and-table-overflow
Open

JakeSCahill wants to merge 2 commits into
mainfrom
jake/toc-anchor-highlight-and-table-overflow

Conversation

@JakeSCahill

Copy link
Copy Markdown
Contributor

Description

Two pre-existing bugs the property reference pages surfaced. The property-links work in redpanda-data/docs 2078 makes in-page jumps common enough that both became obvious.

Wrong "On this page" entry after an anchor jump. An anchor jump was offset twice: html carries scroll-padding-top and the headings carried scroll-margin-top on top of it. The browser parks a linked heading at the sum, while the scroll-spy's activation line is scroll-padding-top alone, so the heading landed below the line and the pass picked the heading above it. On a real page: parked at 180px, line at 104px, so a link to rpc_server highlighted recovery_mode_enabled.

Now one offset, on html, with the headings' breathing room folded in. Browser and scroll-spy read the same value. Hash navigation is also authoritative now, because onScroll cannot see an in-page click at all: a hash change does not always move the scroll position enough to fire a scroll event, so hashchange previously opened the collapsible group and never moved the highlight.

Tables squeezed by a code block. white-space: pre-wrap was already there, marked NEEDS REVIEW, and is not enough: it wraps between tokens but cannot break inside one, so one long identifier sets the cell's min-content width. cloud_storage_inventory_hash_path_directory: is 44 characters and took the table to 542px inside a 354px phone, crushing the label column to 95px. overflow-wrap: anywhere lowers min-content so the token breaks only when there is no room; break-word does not.

Verification

Measured in a browser against the built pages, not reasoned from the CSS.

  • TOC: four targets, all highlighting the wrong entry before the change and the correct one after. Heading parks at 119px against a 120px line.
  • Table: real markup in a 354px box. Before 542px with 188px of overflow and a 95px label column; after 354px, no overflow, 118px label column.
  • New tests/toc-active-anchor suite pins the behaviour at two landing positions, so it fails if the script goes back to inferring the active entry from pixels. All 17 JS suites pass.

Two toc-collapsible tests asserted the old behaviour deliberately ("the scroll pass picks the heading above"). They now assert the target is active; their group assertions are unchanged.

…ezed by a code block

Two things the property reference pages surfaced. Both were pre-existing; the
property links work just made in-page jumps common enough to notice.

**The wrong TOC entry.** An anchor jump was offset twice: html carries
scroll-padding-top, and the headings carried scroll-margin-top on top of it. The
browser parks a linked heading at the sum, while the scroll-spy's activation
line is scroll-padding-top alone, so the heading landed below the line and the
pass picked the heading above it. Measured on a real page: parked at 180px,
activation line at 104px, so clicking a link to rpc_server highlighted
recovery_mode_enabled.

Fixed at the root: one offset, on html, with the headings' 16/24px of breathing
room folded into it. The browser and the scroll-spy now read the same value, and
a linked heading parks level with the line (119px against 120px). Verified in a
browser on the built pages: four targets, all correct after the change, all
wrong before it.

Also made hash navigation authoritative rather than inferred. onScroll cannot
see an in-page click at all, because a hash change does not always move the
scroll position enough to fire a scroll event, so hashchange only ever opened
the collapsible group and never moved the highlight. It now activates from the
hash, which also keeps this correct if the offsets ever drift apart again.
Pulled the copy-pasted clear/add dance out of three call sites into setActive().

**Tables squeezed by a code block.** white-space: pre-wrap was already there,
marked NEEDS REVIEW, and is not enough: it wraps between tokens but cannot break
inside one, so a single long identifier still sets the cell's min-content width.
`cloud_storage_inventory_hash_path_directory:` is 44 characters and did exactly
that, taking the table to 542px inside a 354px phone and crushing the label
column to 95px. overflow-wrap: anywhere is the keyword that lowers min-content,
so the token breaks only when there is genuinely no room; break-word would not
have helped. Measured with the real markup: 354px and no overflow, label column
back to 118px.

Two of the toc-collapsible tests asserted the old behaviour on purpose, with the
message "the scroll pass picks the heading above". They now assert the target is
active and the heading above it is not; their group assertions are unchanged.
@netlify

netlify Bot commented Sep 18, 2026

Copy link
Copy Markdown

Deploy Preview for docs-ui ready!

Name Link
🔨 Latest commit 6cc40e6
🔍 Latest deploy log https://app.netlify.com/projects/docs-ui/deploys/6aad803d73a8bc00081050f0
😎 Deploy Preview https://deploy-preview-443--docs-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 36 (🔴 down 10 from production)
Accessibility: 89 (no change from production)
Best Practices: 83 (no change from production)
SEO: 89 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 5a2cbdea-4f56-4686-bb71-57f6d2a164ba

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: eda465bf-f04d-4cfe-b7b4-a9081f1a3455

📥 Commits

Reviewing files that changed from the base of the PR and between 2cd3c28 and 417a757.

📒 Files selected for processing (6)
  • package.json
  • src/css/doc-bump.css
  • src/css/doc.css
  • src/js/02-on-this-page.js
  • tests/toc-active-anchor/toc-active-anchor.test.js
  • tests/toc-collapsible/toc-collapsible.test.js

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change makes URL hash targets the active entries in the “On this page” TOC during page load and hash changes. It centralizes active-state handling and supports encoded fragments. Anchor offsets now use html scroll padding without heading scroll margins. Table code blocks can wrap long tokens. New tests cover these behaviors, and the full test command runs the added suite.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Severity of issue fixed: Low

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant syncToHashTarget
  participant setActive
  participant scrollActiveIntoView
  Browser->>syncToHashTarget: load or hashchange with URL hash
  syncToHashTarget->>setActive: resolve and activate hash target
  setActive->>setActive: clear previous active entry and reveal group
  syncToHashTarget->>scrollActiveIntoView: scroll active entry into view
Loading

Suggested reviewers: michelerp

Merge Risk: ⚪ Minimal · up to 417a7

The updated TOC synchronization and layout behavior has no remaining actionable risk identified in the reviewed change.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 69.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 3 files. (3 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies both primary fixes: incorrect On-this-page highlighting after anchor jumps and table squeezing caused by code blocks.
Description check ✅ Passed The description directly explains both changes, their causes, the implementation, and the verification results. It is fully related to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 69.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 3 files. (3 skipped: 3 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

validate-build.yml names each node --test suite explicitly, so a new one is
invisible to CI until it is listed. tests/toc-active-anchor was passing locally
and would never have run on a PR.

head-meta, property-tooltips and negative-cache are in the same position and
predate this; left alone here rather than widened in a fix for something else.
@JakeSCahill
JakeSCahill requested a review from a team September 21, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants