Repository navigation
Keep the API search open until the clicked page loads - #4839
Merged
Merged
Conversation
A click on a result closed the dropdown at once, while the boosted htmx request was still in flight. The reader saw the old page with no cue for a moment. The dropdown now waits for `htmx:afterRequest` of the clicked link and shows the input spinner meanwhile. Escape or typing aborts the request. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4839/ |
`pointer-events: none` stops mouse clicks on the other results, but a reader can still focus another result link and press Enter. Its request then races the one in flight. `NavigationSearch` now cancels `htmx:beforeRequest` for any other result while a navigation is pending. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
The API sidebar search now stays open after a reader clicks a result or presses Enter, and closes once htmx has swapped the new page in. Meanwhile the search input shows its spinner, so the reader sees that the page is loading.
Affects: Site UI, API reference
Prompt summary: Clicking a result in the API navigation search closes the dropdown at once, while the next page can still take a moment to load, which feels odd. The ask is to close the dropdown only when the page has loaded, in the way that fits htmx best.
Why
A click on a result closes the dropdown in the same click event. The boosted htmx request for the next page is still in flight, so the reader sees the old page with no dropdown and no sign of progress. On a slow response that gap is long enough to look like the click did nothing.
What
Wait for the request of the clicked link
htmx sends the request from its own listener on the link, before the React
onClickruns.NavigationSearchlistens forhtmx:beforeSendfrom its own result links and remembers the link. It closes the dropdown onhtmx:afterRequestfor that link. htmx fires that event after the swap, and also on an error, abort or timeout, so the dropdown cannot stay stuck. The component usesbeforeSend, notbeforeRequest, because preloads and the new-tab and full-page-load paths inhtmx-hooks.tscancelbeforeRequestand never send.Close at once when nothing is sent
A click that starts no htmx request still closes the dropdown at once, as before. A same-page
#fragmentlink is an example. Cmd, Ctrl and Shift clicks still open a new tab and leave the dropdown open.Cancel and loading state
Escape during the load aborts the request and closes the dropdown. Typing aborts the request and keeps the results open. The input shows its spinner and the result list is
aria-busyand ignores further clicks. The component also cancelshtmx:beforeRequestfor any other result while one is pending, so a result reached with Tab and Enter cannot race the first request. Enter now clicks the selected link and goes through the same path as a mouse click.Out of scope:
ModalSearchhas a similar pattern that closes onhtmx:afterSwaponly. A shared hook for both components is a possible follow-up.Verify
mise run site:test # NavigationSearchWrapper while htmx loads the result — stays open, Enter, Escape abort, typing abortThe search box renders only on assembler builds. To see it, run an assembler build with
FEATURE_ASSEMBLER_API_EXPLORER=trueand serve it. Then open/docs/api/doc/elasticsearch/, set network throttling to Slow 3G, type in the sidebar search and click a result.🤖 Generated with Claude Code