Home > widget-integration > InstantSearchModule
InstantSearchModule class
Instant Search Widget Module
Provides a unified, framework-based instant search system for Shopify themes.
**Features**: - Search-as-you-type with debounced API requests - Multiple display styles (dropdown, full-width overlay) - 20+ theme auto-detection and integration - Full keyboard accessibility (WCAG compliant) - Recent searches management - Custom events for extensibility
**Migration from Legacy**:
| Legacy | New Module | |-------------------------------------|-------------------------------------| | handleInstantSearchWidget(context) | window.boostISWModule.initISWWithContext(settings) | | Global functions with context param | DI-based services | | Hard-coded selectors | Theme config map | | Inline event handling | Controller with state management |
**Technical Support Extension**:
window.boostWidgetIntegration.extend('InstantSearchModule', (InstantSearchModule) => {
return class CustomISWModule extends InstantSearchModule {
async onInitBlock(block) {
// Add custom tracking
await super.onInitBlock(block);
}
};
});
Signature:
export declare class InstantSearchModule
Constructors
|
Constructor |
Modifiers |
Description |
|---|---|---|
|
Constructs a new instance of the |
Properties
|
Property |
Modifiers |
Type |
Description |
|---|---|---|---|
|
| |||
|
|
boolean |
Whether the block has been fully initialized (including click listeners, bundles, etc.) | |
|
|
boolean |
Whether the module has been initialized with context | |
|
|
Array<Record<string, unknown>> |
Current bundles from the latest search render (updated via boost-sd-isw-rendered event) | |
|
|
Instance of the InstantSearchAPI | ||
|
|
Instance of the InstantSearchController | ||
|
|
Instance of the InstantSearchSelectors | ||
|
|
Instance of the InstantSearchService | ||
|
|
ModuleRefImpl | ||
|
|
Instance of the RecentSearchService | ||
|
|
boolean |
Whether services have been resolved from DI |
Methods
|
Method |
Modifiers |
Description |
|---|---|---|
|
Add a recent search. | ||
|
Re-bind search inputs. Call this after dynamically adding new search inputs to the page. **Legacy**: Required manual event binding **New**: bindSearchInputs() | ||
|
|
Call afterRender customization hooks if configured. Supports both block-specific and global afterRender callbacks defined via | |
|
Clear all recent searches. | ||
|
Close suggestion dropdown/overlay. **Legacy**: closeSuggestion(context, input?) / onCloseSuggestion(context, input?) **New**: closeSuggestion() | ||
|
Get recent searches. | ||
|
Get current suggestion data. **Legacy**: context.useContextState('instant-search')[0]() **New**: getSuggestionData() | ||
|
Get theme search configuration. **Legacy**: Hard-coded selectors **New**: getThemeSearchConfig() | ||
|
Handle input change event. For legacy compatibility. | ||
|
Handle keydown event. For legacy compatibility. | ||
|
|
Handle clicks on popular suggestions and no-result suggestions to save them as recent searches. | |
|
|
Initialize dynamic bundle and volume bundle integrations for ISW. Bundle modules are loaded on demand so they can register their own TAE listeners only when the instant-search block is initialized. | |
|
Initialize ISW with search settings. **Legacy**: handleInstantSearchWidget(context) **New**: initISWWithContext(searchSettings) | ||
|
|
Called when an instant search block is registered. Resolves services, exports the module to On mobile/tablet (< 991 px) the ISW initializes immediately because users interact with the search input right away. On desktop, initialization is deferred until the first | |
|
Open suggestion dropdown/overlay. **Legacy**: openSuggestion(context, input) / onOpenSuggestion(context, input) **New**: openSuggestion(input?) | ||
|
|
Resolve DI service instances (idempotent). | |
|
Trigger a search. **Legacy**: requestSuggestionDebounce(context, query) **New**: search(query) | ||
|
|
Set up click delegation for the ISW block. Handles watermark clicks, recent search suggestion clicks, bundle product clicks, and locale-aware link navigation. | |
|
|
Sets up the TAE App block listener for instant search widget. Follows the same pattern as FilterModule.setupBlockListener(), RecommendationModule.setupBlockListener(), etc. Override this method to customize block detection or support additional block types. | |
|
Toggle suggestion visibility. **Legacy**: N/A **New**: toggleSuggestion() |