Conversation
API paths (`/docs/api/…`) were classified as external URLs in `assemblerStrategy.isExternalDocsUrl`, so every sidebar click on an API page bypassed HTMX and called `window.location.assign`. That caused a full-page reload — the top nav and sidebar visibly redrew and the accordion state reset on every navigation. Returning `false` from `isExternalDocsUrl` lets HTMX handle these links. The existing `shouldRetargetApiContentSwap` logic then swaps only `#api-content-grid`, leaving `#pages-nav` and the secondary nav untouched. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4155/ |
There was a problem hiding this comment.
Requesting changes: please align the HTMX link behavior tests with the new assembler API-link routing contract before merge.
What is this? | From workflow: PR Review
Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.
| export const assemblerStrategy: HtmxUrlStrategy = { | ||
| isExternalDocsUrl: (url) => | ||
| url === apiRoot || url.startsWith(`${apiRoot}/`), | ||
| isExternalDocsUrl: () => false, |
There was a problem hiding this comment.
[MEDIUM] Update assembler HTMX link tests to match this new contract
This change flips API links from external to internal for assembler, but the existing suite still asserts the old behavior in useHtmxLink.test.tsx (for example, isExternalDocsUrl('/docs/api') === true and expecting hx-disable on /docs/api/...). That makes the test suite inconsistent with this implementation and likely to fail once those tests run. Please update those assertions to validate HTMX handling for API links instead of external-link handling.
`useHtmxLink` and `useHtmxContainer` tests expected `hx-disable` on `/docs/api/…` paths. Since `isExternalDocsUrl` now returns `false` for all docs paths, API links are treated as internal: `htmx.process` is called and no `hx-disable` attribute is set. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Approved.
What is this? | From workflow: PR Review
Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.
API sidebar links were doing a full-page reload on every click, causing the top nav and sidebar accordion to visibly redraw and reset their state between operations.
Affects: Site UI, API reference
Prompt summary: The user noticed that clicking sidebar links in the API section causes the top menu to redraw and the sidebar submenu to collapse and reopen — a blinking effect that does not happen in the regular docs section.
Why
assemblerStrategy.isExternalDocsUrlreturnedtruefor any path under/docs/api/. Inmain.ts, a boosted link thatisExternalDocsUrlclassifies as external skips HTMX entirely and callswindow.location.assign. Every API sidebar click therefore triggered a full-page reload: the secondary nav, the sidebar, and its accordion state were all rebuilt from scratch on landing.What
HTMX now handles API navigation
isExternalDocsUrlinassembler.tsreturnsfalseunconditionally. API links on the assembler build are same-origin docs paths and belong in the HTMX navigation flow. The comment that described/docs/apias "a separate app" is no longer accurate — the API explorer is rendered by the same docs-builder server.The existing retargeting logic now fires for API-to-API navigation
shouldRetargetApiContentSwapinpages-nav.tswas already wired up to detect API-page-to-API-page navigations and retarget the HTMX swap to#api-content-gridonly. With the full-page-reload bypass removed, this logic now runs. Only the content column is swapped;#pages-navand the secondary nav are left untouched.Verify
Run the assembler locally with the API explorer enabled:
Open an API operation page (e.g.
/docs/api/doc/elasticsearch/operation/operation-search-application-get-behavioral-analytics) and click several sidebar links. The top nav and sidebar should stay in place without any redraw or accordion collapse between navigations.🤖 Generated with Claude Code