feat(recent-searches): export storage and search APIs #473
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.
This creates a programmatic API to add and remove items from the Recent Searches instance, and exports the search and highlight APIs.
This will likely be the foundation of the upcoming Recently Viewed Items plugin.
Changes
Recent Item structure
The Recent Item structure changed to be decoupled from the Algolia Query Suggestions hit.
(This change will likely "break" current Autocomplete Recent Searches implementation by displaying an empty title, but it's time before we release widely. If so, run
localStorage.clear()
)API
Manipulate items with the Data API
addHighlightedAttribute({ item, query })
This function is now exported.
search({ items, query, limit })
This function is now exported.
Recently Viewed Items plugin
I created a user-land Recently Viewed Items plugin based on these new APIs.
This plugin is in a sandbox that displays the items on the empty screen for now. When supporting the official plugin, we'll think about a better integrated UX when searching for recently viewed items.