Skip to content

Keep the same API page when switching versions - #4978

Merged
reakaleek merged 3 commits into
mainfrom
version-switch-api-root-r-629c7ff3
Nov 20, 2026
Merged

reakaleek merged 3 commits into
mainfrom
version-switch-api-root-r-629c7ff3

Conversation

@reakaleek

@reakaleek reakaleek commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Switching the version on an API operation page now opens the same operation in the other version, not that version's landing page.

Affects: API reference, Site UI

Prompt summary: Find out why the version switcher on an API operation page, such as operation-async-search-status on docs-edge.elastic.dev, sends the reader to the API root. Fix it with the smallest change.

Why

The API pages render the right per-operation links in the version picker. A click on a sidebar link replaces only the page content, so the picker is updated in place by rewriting each link's href. htmx reads a boosted link's href once, when it first processes the link, so a later click still requests the page the link pointed at on first load. A reader who lands on /docs/api/elasticsearch, opens an operation and picks v8 ends up on /v8. A fresh load of the operation URL works, which hides the bug.

What

The picker is replaced and processed again

After each boosted swap, syncApiVersionSwitcher replaces #api-version-switcher with the one in the response and calls htmx.process on it. htmx then reads the new href values and a click requests the page the reader sees. The check that the old and new pickers list the same number of versions is gone, because a replacement does not match links by position.

Tests check the picker, not only its attributes

The unit tests now assert that the live picker is the one from the response and that htmx processes it. The old test read only the href attribute, so it passed while clicks still went to the wrong page. htmx is mocked in this suite because jsdom cannot run it, so the click itself is covered by the journey below.

The edge journey switches version from an operation

browse-api.journey now opens operation-async-search-status in v8 by a link click, switches to the latest version and expects the same operation on the versionless URL. The operation exists in both majors, so a switch to the wrong page fails the journey.

Verify

mise run site:test
mise run site:check

The journey runs against a deployed site and needs a version of the API to switch to, so it fails against edge until this ships.

mise run journeys:synth edge

I also reproduced the bug and the fix in Chromium against docs-edge.elastic.dev. With edge's current bundle, landing page → operation → v8 → v9 ends on /v8, then on /docs/api/elasticsearch. With this branch's bundle served in its place, both steps stay on operation-async-search-status.

After a sidebar click, the version picker showed the right links but a click still went to the version's landing page. htmx reads a boosted link's `href` once, when it processes the link, so rewriting the attribute had no effect. The sync now replaces the picker with the one in the response and has htmx process it.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@reakaleek
reakaleek requested a review from a team as a code owner November 20, 2026 06:33
@reakaleek reakaleek added the bug label Nov 20, 2026
@reakaleek
reakaleek requested a review from akira28 November 20, 2026 06:33
reakaleek and others added 2 commits November 20, 2026 07:41
…r review by @infra-vault-gh-plugin-prod)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…per review by @infra-vault-gh-plugin-prod)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

@reakaleek
reakaleek merged commit 8ed9549 into main Nov 20, 2026
44 checks passed
@reakaleek
reakaleek deleted the version-switch-api-root-r-629c7ff3 branch November 20, 2026 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant