Skip to content

Let navigation-search filter by a type attribute - #4144

Merged
reakaleek merged 3 commits into
feat/nav-search-accept-api-hitsfrom
feat/nav-search-type-attribute
Sep 22, 2026
Merged

reakaleek merged 3 commits into
feat/nav-search-accept-api-hitsfrom
feat/nav-search-type-attribute

Conversation

@reakaleek

@reakaleek reakaleek commented Sep 18, 2026

Copy link
Copy Markdown
Member

<navigation-search type="api"> now requests /v1/navigation-search with type=api. Callers that omit the attribute stay unfiltered.

Affects: Site UI, Search

Prompt summary: Second stacked PR for the Jump to page API story. Implement elastic/docs-eng-team#858 on top of elastic/docs-builder#4143: add a type attribute, apply it to the store filter, and keep unfiltered callers unchanged.

Stack: 2 of 5, on top of #4143.

Why

The API sidebar needs Jump to page to request only API results. Every other host of the element stays unfiltered.

Closes elastic/docs-eng-team#858

What

Type attribute

The custom element accepts a type string. docs or api is passed into the search query on that render. Any other value, including an omitted attribute, keeps the request unfiltered.

Placeholder

When type is api and no placeholder is set, the box shows Jump to API.

Verify

cd src/Elastic.Documentation.Site && npm run test
# requests navigation-search with type=api when type is api
# filters the first query when health is cached and a search term is already set
# leaves the query unfiltered when type is omitted

Out of scope: Mounting the box in the API sidebar. That is the next PR.

@reakaleek
reakaleek requested a review from a team as a code owner September 18, 2026 10:29
@reakaleek
reakaleek requested a review from akira28 September 18, 2026 10:29
@reakaleek
reakaleek added this pull request to stack #4146 September 18, 2026 10:35

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — no actionable issues found.


What is this? | From workflow: PR Review

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

@reakaleek
reakaleek force-pushed the feat/nav-search-type-attribute branch from 6110f71 to ef216c9 Compare September 18, 2026 12:23
@github-actions

Copy link
Copy Markdown
Contributor

Docs preview (local build)

Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4144/

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: there is one medium-severity correctness issue in the inline comment that should be addressed before merge.


What is this? | From workflow: PR Review

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

const { setTypeFilter } = useSearchActions()
const typeFilter = parseTypeFilter(type)

useEffect(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] type filter is applied after the first render, so the first query can be unfiltered

setTypeFilter(typeFilter) runs in useEffect, which executes after render. If the shared store still has a non-empty searchTerm from a previous mount, useNavigationSearchQuery can fire immediately with stale typeFilter='all' before this effect runs, returning mixed docs/API results even when type="api" is set.

Please initialize the filter before query evaluation (for example by deriving query filter directly from the prop for initial render, or by ensuring mount-time state is set synchronously before NavigationSearch runs its query hook).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5a7a77f — the type filter is written during render, before NavigationSearch mounts, so a cached health check cannot query with the previous filter.

reakaleek and others added 2 commits September 22, 2026 09:37
The API sidebar must send type=api without changing unfiltered callers. Clearing the box must keep that host filter.

Co-Authored-By: Cursor Grok 4.6 <noreply@anthropic.com>
A cached health check mounts search on the first render. An effect applies
the filter after that query, so a leftover search term can run unfiltered.

Co-Authored-By: Grok 4.7 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@reakaleek
reakaleek force-pushed the feat/nav-search-type-attribute branch from 5a7a77f to 49d3ff7 Compare September 22, 2026 07:38

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: the inline comment identifies a correctness issue where the new type behavior is shared globally across instances instead of being instance-scoped.


What is this? | From workflow: PR Review

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

The attribute is already known on this render. Reading it from the store
lets a cached health check query before the filter is applied.

Co-Authored-By: Grok 4.7 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — no actionable issues found.


What is this? | From workflow: PR Review

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

@reakaleek
reakaleek merged commit 616b705 into main Sep 22, 2026
36 checks passed
@reakaleek
reakaleek deleted the feat/nav-search-type-attribute branch September 22, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants