Repository navigation
Keep the same API page when switching versions - #4978
Merged
Merged
Conversation
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]>
…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]>
Contributor
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4978/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-statusondocs-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'shrefonce, 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 picksv8ends 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,
syncApiVersionSwitcherreplaces#api-version-switcherwith the one in the response and callshtmx.processon it. htmx then reads the newhrefvalues 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
hrefattribute, 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.journeynow opensoperation-async-search-statusinv8by 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
The journey runs against a deployed site and needs a version of the API to switch to, so it fails against
edgeuntil this ships.I also reproduced the bug and the fix in Chromium against
docs-edge.elastic.dev. With edge's current bundle, landing page → operation →v8→v9ends on/v8, then on/docs/api/elasticsearch. With this branch's bundle served in its place, both steps stay onoperation-async-search-status.