Skip to content

fix: restore search history and suggestions in Autocomplete dropdown - #456

Open
Sumit-ai-dev wants to merge 1 commit into
StatTag:masterfrom
Sumit-ai-dev:fix/search-suggestions-history
Open

fix: restore search history and suggestions in Autocomplete dropdown#456
Sumit-ai-dev wants to merge 1 commit into
StatTag:masterfrom
Sumit-ai-dev:fix/search-suggestions-history

Conversation

@Sumit-ai-dev

Copy link
Copy Markdown
Contributor

Prerequisites

  • I have read the CONTRIBUTING guidelines.
  • I have added tests to cover my changes.
  • All new and existing tests passed locally.
  • I have run the lint-staged formatter locally and the code style matches the project standard.

Expected Behavior

Clicking an item from the Search History or live suggestions dropdown fires the search and loads results instantly.

Current Behavior

enableSuggestions is disabled in search-config.js because clicking a dropdown item updates the text box but the search never runs; you just get 0 results. On top of that, the searchHistory array wasn't even being shown in the dropdown.

Possible Solution

  • The root cause: <Autocomplete> fires two separate events — onInputChange for typing and onChange for clicking. Only onInputChange was wired up, so clicks on dropdown items were completely ignored.
  • Added handleOptionSelect and wired it to onChange so clicking a suggestion actually triggers the search.
  • Merged searchHistory into the dropdown options alongside live suggestions (deduplicated with Set) so history items actually show up.
  • Removed the suggestions.includes() guard that was silently blocking history items from ever running a search.
  • Re-enabled enableSuggestions: true in search-config.js and cleaned up the TODO comment.

Fixes #455

Your Environment

  • OS: macOS
  • Node version: 22.21.1
  • StatWrap version: (Development branch)

Screenshots

1. Search history properly showing in the dropdown after re-enabling the feature:
Screenshot 2026-09-09 at 4 27 34 PM

2. After clicking 'Data' from the history dropdown, the search instantly executes and loads the results instead of showing 0 results:
Screenshot 2026-09-09 at 4 26 33 PM

- Add missing onChange handler (handleOptionSelect) to Autocomplete
  component so clicking a dropdown item correctly fires a search
- Merge searchHistory and live suggestions into a single deduplicated
  options array so both appear in the dropdown
- Remove broken suggestions.includes() guard from handleAutocompleteChange
  that was preventing history items from triggering searches
- Re-enable enableSuggestions flag in search-config.js now that the
  underlying React event wiring is correct

Fixes the bug introduced during the FlexSearch refactor (PR StatTag#281) where
selecting an item from search history would show 0 results.
@Sumit-ai-dev

Copy link
Copy Markdown
Contributor Author

Hey @lrasmus! The PR is up and ready for review whenever you have a chance. Happy to tweak or change anything if you need me to!

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.

Bug: Search History & Suggestions show 0 results when clicked

1 participant