Overview
History Queries is a powerful module that tracks user search behavior and presents it as clickable suggestions. This helps users quickly access their previous searches without retyping, improving the search experience and reducing friction.Key Features
- Persistent Storage: Queries are saved to browser storage and persist across sessions
- Query Filtering: Hides queries that match the current search to avoid redundancy
- Session Management: Tracks queries within a session with configurable TTL
- Customizable Display: Multiple components for different presentation styles
- Remove Individual Items: Users can delete specific queries from history
- Clear All: Bulk delete all history queries
Components
HistoryQueries
The main component that renders a filtered list of history query suggestions. It inherits fromBaseSuggestions and provides slots for customization.
Props
| Name | Type | Default | Description |
|---|---|---|---|
animation | Vue Component | "ul" | Animation component for list transitions |
maxItemsToRender | number | 5 | Maximum number of queries to display |
Slots
suggestion: Customize the entire history query item- Bindings:
suggestion(HistoryQuery object),index(number)
- Bindings:
suggestion-content: Customize the content within each suggestion- Bindings:
suggestion,index
- Bindings:
suggestion-remove-content: Customize the remove button icon/text- Bindings:
suggestion,index
- Bindings:
Usage
With Animation
Custom Content
HistoryQuery
Renders an individual history query suggestion with a clickable button to select it and a remove button to delete it from history.Props
| Name | Type | Required | Description |
|---|---|---|---|
suggestion | HistoryQuery | Yes | The history query data to render |
suggestionClass | string | No | CSS class for the suggestion button |
removeButtonClass | string | No | CSS class for the remove button |
Events
UserSelectedAHistoryQuery: Emitted when user clicks the suggestion- Payload:
HistoryQueryobject
- Payload:
Slots
default: Customize the suggestion content- Bindings:
suggestion,query
- Bindings:
remove-button-content: Customize remove button- Bindings:
suggestion
- Bindings:
Usage
With Custom Content
MyHistory
Displays the complete search history grouped by date. Ideal for a dedicated history page or panel.Props
| Name | Type | Default | Description |
|---|---|---|---|
animation | Vue Component | "ul" | Animation component for transitions |
locale | string | "en" | Locale for date/time formatting |
queriesListClass | string | undefined | CSS class for query lists |
Slots
date: Customize date header display- Bindings:
date(formatted string)
- Bindings:
suggestion: Customize individual query items- Bindings:
suggestion,index,formatTime(function)
- Bindings:
suggestion-content: Customize query content- Bindings:
suggestion,index,formatTime
- Bindings:
suggestion-remove-content: Customize remove button- Bindings:
suggestion,index
- Bindings:
Usage
With Custom Date Format
With Custom Content
ClearHistoryQueries
A button component that clears all history queries when clicked. Automatically disables when history is empty.Events
UserPressedClearHistoryQueries: Emitted when button is clicked
Slots
default: Button content (text, icon, or both)
Usage
Configuration
Configure the History Queries module during X Components installation:Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
debounceInMs | number | - | Debounce time for setting module query |
maxItemsToStore | number | - | Maximum history queries in browser storage |
hideIfEqualsQuery | boolean | - | Hide query if it matches current search |
sessionTTLInMs | number | - | Session timeout in milliseconds |
Events
The History Queries module emits the following events:User Interaction Events
UserSelectedAHistoryQuery: User clicked a history query- Payload:
HistoryQueryobject
- Payload:
UserPressedRemoveHistoryQuery: User clicked remove on a query- Payload:
HistoryQueryobject
- Payload:
UserPressedClearHistoryQueries: User clicked clear all button- Payload:
void
- Payload:
UserClickedEnableHistoryQueries: User enabled history tracking- Payload:
void
- Payload:
UserClickedDisableHistoryQueries: User disabled history tracking- Payload:
void
- Payload:
State Change Events
HistoryQueriesDisplayed: Queries displayed to user- Payload:
HistoryQuery[]
- Payload:
HistoryQueriesQueryChanged: Search query for filtering changed- Payload:
string
- Payload:
SessionHistoryQueriesChanged: Session queries updated- Payload:
HistoryQuery[]
- Payload:
HistoryQueriesStorageKeyChanged: Browser storage key changed- Payload:
string
- Payload:
Integration Patterns
In Empathize Layer
Display history queries alongside other suggestions in the Empathize predictive layer:Dedicated History Page
Create a full history view with clear functionality:With Custom Styling
Best Practices
Storage Limits
Set appropriate storage limits based on your use case:Privacy Considerations
Provide users control over their history:Session Management
Adjust session TTL based on your application:Query Filtering
Enable filtering to avoid showing duplicate current queries:Related Components
- Empathize - Predictive layer container
- Query Suggestions - AI-powered suggestions
- Popular Searches - Trending searches
- Base Components - Foundational UI components
