Skip to content

Enhance toolbox search: index categories, normalize queries, add category open buttons and styles#328

Closed
tracygardner wants to merge 1 commit intomainfrom
codex/add-categories-to-toolbox-search-results
Closed

Enhance toolbox search: index categories, normalize queries, add category open buttons and styles#328
tracygardner wants to merge 1 commit intomainfrom
codex/add-categories-to-toolbox-search-results

Conversation

@tracygardner
Copy link
Contributor

Motivation

  • Improve the Blockly toolbox search to include category results and make queries more robust across localization and whitespace differences.
  • Surface category results in the search flyout and allow users to jump into toolbox categories from search results.
  • Provide visual affordance for category search hits by adding CSS styling for flyout buttons.

Description

  • Replaced getBlocksFromToolbox with getSearchableToolboxItems that returns both toolboxBlocks and toolboxCategories, and avoids indexing search-only toolbox entries.
  • Added query normalization helpers normalizeSearchSegment and normalizePathKey, and resolveToolboxName/resolveCategoryColour to handle localized names and category colours/styles consistently.
  • Indexes category meta entries alongside blocks, appends category entries to the search index, and adds category buttons to the flyout via createXmlFromJson + button XML when a match is a category.
  • Implemented a scoreMatch comparator to prioritize category matches, exact matches, prefixes, and then alphabetic order, and wired sorting into showMatchingBlocks.
  • Registered a SEARCH_OPEN_CATEGORY button callback that finds the matching toolbox category, expands parents, selects it, and focuses the toolbox/flyout to open the category contents.
  • Added CSS rules in style.css for .blocklyFlyoutButton.search-category-result to style category-result buttons with a configurable --search-category-colour variable.
  • Kept the existing behavior of deferring index builds (using requestIdleCallback / setTimeout) and preserved existing search initialization patching logic.

Testing

  • Ran lint and static checks via npm run lint and they completed successfully.
  • Built the frontend with npm run build and the build succeeded without errors.
  • Executed the test suite with npm test and all automated tests passed.

Codex Task

@tracygardner tracygardner deleted the codex/add-categories-to-toolbox-search-results branch February 27, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant