EDU-16758: fix API reference hash navigation#1268
Merged
PedroAntunesCosta merged 4 commits intoMay 26, 2026
Merged
Conversation
✅ Deploy Preview for elated-hoover-5c29bf ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Performance ResultsPage /docs/api-reference/buying-policies-api#get-/-accountName-/authorization-dimensionsComplete results here Page /docs/api-reference/logistics-api#get-/api/logistics/pvt/configuration/pickuppoints/-pickupPointId-Complete results here Page /docs/guides/vtex-io-documentation-creating-an-interface-for-your-app-settingsComplete results here Page /docs/troubleshooting/my-google-tag-assistant-is-not-working-with-partytownComplete results here Page /updates/release-notes/2026-05-08-marketplace-payment-data-can-now-be-shared-with-sellersComplete results here Overall Performance |
|
A total of 2 tests failed! API guides documentation page1 failing tests:
API reference documentation page1 failing tests:
For more information, open the cypress action summary page. |
carolinamenezes
approved these changes
May 26, 2026
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.
Summary
Fixes the API reference (
/docs/api-reference/[slug]) navigation so the RapiDoc focused viewer stays in sync with the URL hash across deep links, sidebar clicks, and same-slug Next-Link transitions between endpoints.Changes
src/pages/docs/api-reference/[slug].tsxsyncHasheffect mirrorswindow.location.hash(and the legacy?endpoint=query) intoclientHashstate and forwards the new path to RapiDoc viarapidoc.current.scrollToPath(...).hashchangeplus the Next routerhashChangeCompleteandrouteChangeCompleteevents, and re-runs whenslugchanges.scrollDocandrouter.push(window.location.href)effects that fought with RapiDoc's internal handlers.route-prefix="#"on the<rapi-doc>element so RapiDoc never auto-picks?endpoint=as its router prefix on bare-slug loads.window.scrollTo({ top: 0 })reset on overview→endpoint transitions.RapiDocsubmodule pointer bumped to include the companion fix ingetElementIDFromURL().Why
The page renders two views per slug — overview (no hash, server-rendered, indexable) and endpoint (with hash, RapiDoc focused viewer). Before this change, deep links with a hash and same-API endpoint→endpoint navigation via the sidebar would render the API overview or the wrong endpoint. Two compounding causes:
routePrefixwould default to?endpoint=on bare-slug loads, so itsgetElementIDFromURL()returned the entire URL on every spec (re)load and the focused template fell back to the first endpoint.routeChangeComplete/hashChangeCompletebut not the nativehashchange, so neither the page nor RapiDoc's internal listener was re-syncing on those navigations.Fix verified locally with Playwright across cold-loads (with/without hash), overview-table clicks, sidebar clicks (same API and across APIs), and Previous/Next pagination.
Related Task
EDU-16758
Companion PR
Depends on vtexdocs/RapiDoc#47 (submodule pointer in this PR is at the fix commit on the fork branch). Once that PR merges, the submodule pointer should be re-pinned to the merged commit on
vtexdocs/RapiDoc:master.