Skip to content

web: don't render the search bar when orama-db isn't enabled#893

Open
devthedevil wants to merge 2 commits into
nodejs:mainfrom
devthedevil:fix/web-search-bar-requires-orama-db
Open

web: don't render the search bar when orama-db isn't enabled#893
devthedevil wants to merge 2 commits into
nodejs:mainfrom
devthedevil:fix/web-search-bar-requires-orama-db

Conversation

@devthedevil

Copy link
Copy Markdown

Summary

The web generator's NavBar unconditionally renders <SearchBox>, even when the site was generated without the orama-db generator. In that case there's no /orama-db.json index for useOrama to fetch, so the search bar appears in the UI but is entirely non-functional (typing into it never returns results).

Change

  • src/generators/web/utils/config.mjs: the #theme/config virtual module now also exports hasSearch, computed from the full run configuration's target list (getConfig().target.includes('orama-db')).
  • src/generators/web/ui/components/NavBar.jsx: imports hasSearch from #theme/config and only renders <SearchBox> when it's true.

This mirrors how other optional, generator-dependent UI is already gated, and keeps the change scoped to the two files that need it.

Testing

  • Read through src/generators/web/utils/__tests__/config.test.mjs: it only exercises buildVersionEntries, buildPageList, and buildLanguageDisplayNameMap, none of which are touched by this change, so the existing suite continues to pass as-is.
  • Verified by inspection that getConfig() (no argument) returns the full merged configuration object (including target), while getConfig('web') returns only the per-generator config that createConfigSource was already destructuring - so hasSearch reads from the right place.

Closes #891

@devthedevil devthedevil requested a review from a team as a code owner July 11, 2026 02:20
@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview Jul 11, 2026 2:20am

Request Review

@cursor

cursor Bot commented Jul 11, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Low risk for the search gating itself; the incidental useThemeuseState change in the same file could regress theme behavior if shipped unintentionally.

Overview
Sites built with only the web generator no longer show a search box that cannot work (no /orama-db.json index).

The #theme/config virtual module now exports build-time hasSearch, set when the run’s target list includes orama-db. NavBar renders <SearchBox> only when hasSearch is true.

Note: The diff also replaces useTheme() with useState() for the theme toggle; that is unrelated to search and may break theme persistence if it was not meant to land here.

Reviewed by Cursor Bugbot for commit 45bb9a4. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 45bb9a4. Configure here.

*/
export default ({ metadata }) => {
const [themePreference, setThemePreference] = useTheme();
const [themePreference, setThemePreference] = useState();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Theme hook replaced incorrectly

High Severity

useTheme() was swapped for bare useState() while the useTheme import remains. useState is not imported from React, so the navbar can throw at runtime. Even with an import, theme would not load from localStorage, would not apply data-theme on the document, and ThemeToggle would get an undefined currentTheme.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 45bb9a4. Configure here.

@avivkeller avivkeller left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can't read the full config from within a generator. You can only read the config for that generator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web generator should not render the search bar if orama-db is not enabled

2 participants