Home > widget-integration > InstantSearchController
InstantSearchController class
Controller for instant search UI interactions.
Signature:
export declare class InstantSearchController
Example
window.boostWidgetIntegration.extend('InstantSearchController', (InstantSearchController) => {
return class CustomController extends InstantSearchController {
// Add custom analytics on open
async openSuggestion(input) {
this.trackOpen();
await super.openSuggestion(input);
}
};
});
Constructors
|
Constructor |
Modifiers |
Description |
|---|---|---|
|
Constructs a new instance of the |
Properties
|
Property |
Modifiers |
Type |
Description |
|---|---|---|---|
|
| |||
|
|
Map<string, EventListener> |
Bound event handlers for cleanup | |
|
|
Array<Record<string, unknown>> |
Current bundles from the latest render (for keyboard Enter handling) | |
|
|
DefaultSuggestionData | null |
Default suggestion data | |
|
|
MutationObserver | null |
MutationObserver for dialog integration cleanup | |
|
|
((e: KeyboardEvent) => void) | null |
Escape keydown handler stored for cleanup | |
|
|
ReturnType<typeof setTimeout> | null |
Delayed focus timer from openFullWidth — must be canceled on close/destroy | |
|
|
((e: KeyboardEvent) => void) | null |
Focus-trap keydown handler stored for cleanup | |
|
|
boolean |
Whether controller is initialized | |
|
| |||
|
| |||
|
| |||
|
|
boolean |
Guard flag to prevent ISW from reopening during a close cycle | |
|
|
boolean |
Prevent concurrent renders | |
|
|
string |
Original query typed by the user before keyboard navigation started | |
|
| |||
|
|
boolean | null |
Previous mobile state for responsive breakpoint change detection | |
|
|
Promise<void> | ||
|
| |||
|
|
HTMLElement | null |
Saved focus element for restoration | |
|
|
(() => void) | null |
Scroll handler cleanup function from position service | |
|
|
SearchSettings$1 | null |
Search settings cache | |
|
| |||
|
|
string |
Cached ISW template |
Methods
|
Method |
Modifiers |
Description |
|---|---|---|
|
|
Close the panel on Escape, from anywhere inside it. Registered for every layout: Stored in | |
|
|
Activate focus trap for full-width overlay mode. Prevents Tab / Shift+Tab from leaving the overlay, keeping keyboard focus cycling through interactive elements inside the ISW wrapper. Stored in **WCAG**: SC 2.1.2 No Keyboard Trap — the trap is intentional (modal-like overlay) and Escape always escapes it, via | |
|
|
Announce search result count to screen readers via an ARIA live region. Creates a visually-hidden **WCAG**: SC 4.1.3 Status Messages (Level AA) | |
|
|
Apply widget styles to the ISW container element. Called once during | |
|
|
Wait for an element's CSS animation to finish by polling its position. Polls the element's **Legacy**: | |
|
|
Bind event handlers to an input. | |
|
Bind event handlers to search inputs. **Legacy**: Part of initInstantSearchWidgetEvents() **New**: Separated method for rebinding | ||
|
|
Remove inline body styles that some themes apply via a native These styles are NOT removed by clearing CSS classes, so they must be explicitly stripped as inline properties when ISW closes. Override to restore or preserve specific properties for a given theme. | |
|
|
Release an attribute-based theme scroll lock left behind when ISW closed the theme's search dialog. Horizon 2025+ locks scroll with a Delegates the guard logic to | |
|
|
Close dropdown style. | |
|
|
Close full-width overlay. Legacy onCloseSuggestion does NOT differentiate full-width vs dropdown — it always hides the same | |
|
|
Close the theme Override to apply a custom close strategy for a specific theme (e.g. clicking a close button instead of calling | |
|
Close suggestion dropdown/overlay. **Legacy**: closeSuggestion() / onCloseSuggestion() **New**: closeSuggestion(input?) with state management | ||
|
|
Check whether a string contains HTML tags. | |
|
|
Deactivate the Escape handler, removing the keyboard event listener. | |
|
|
Deactivate focus trap, removing the keyboard event listener. | |
|
|
Simple debounce utility. | |
|
Cleanup event listeners and resources. | ||
|
|
Detect the mobile ISW style from the rendered DOM. - **style1** (full-width overlay): mobile container contains Override to customise detection for non-standard Liquid template structures. | |
|
|
Dispatch rendered event. | |
|
|
Ensure the mobile search bar wrapper is visible. Some themes initially hide the mobile wrapper. This method removes the hide class on user interaction (input, click, focus). **Legacy**: | |
|
|
Get active input element. | |
|
|
Collect all keyboard-focusable elements inside the full-width overlay. | |
|
|
Get all keyboard-navigable items including interactive buttons. Returns items in navigation order: clear button, close button, suggestion items, then view-all products button. **Legacy**: onKeyboardNavigation() counted these separately with index offsets **New**: Single ordered array for clean navigation | |
|
|
Resolve the DOM root for keyboard navigation. ISW renders the mobile and desktop containers side by side and populates both with suggestion markup on every query (see Falls back to the generic container, then | |
|
|
Get shop-specific CSS custom properties to inject into the widget container. Override to provide per-shop theming without touching global CSS. The returned object is applied via | |
|
Get current ISW state. | ||
|
Get current suggestion data. | ||
|
|
Get suggestion items. Scoped to the active container so hidden mobile/desktop duplicates are excluded from keyboard navigation. | |
|
|
Handle Enter on bundle items by dispatching events to DI-based controllers. | |
|
|
Handle dialog integration for dropdown styles. For dropdown styles, observes the theme's **Legacy**: handleDialogIntegrationForDropdownStyles() **New**: handleDialogIntegration() + injectISWIntoDialog() + moveISWBackToBody() | |
|
|
Handle Enter key press. | |
|
Handle input change event. **Legacy**: handleSearchInputChange(context, e, input) + searchInputListener() **New**: handleInputChange(e, input) with state management | ||
|
Handle input click event. Respects | ||
|
Handle input focus event. Respects | ||
|
Handle keydown event for keyboard navigation. **Legacy**: searchInputKeydownListener(context, e, input) **New**: handleKeydown(e, input) with proper state management | ||
|
|
Handle reset button click. | |
|
|
Handle form submit. | |
|
|
Handle submit button keydown for WCAG keyboard activation tracking. **Legacy**: Inline keydown handler on submit button in initInstantSearchWidgetEvents() **New**: Dedicated method for extensibility | |
|
|
Handle Tab key press. | |
|
|
Hide the suggestion panel and clean up body classes. Matches legacy | |
|
Initialize controller without context (basic setup). **Legacy**: Part of handleInstantSearchWidget() **New**: Separated initialization method | ||
|
Initialize controller with full context. **Legacy**: initInstantSearchWidget(context) + initInstantSearchWidgetEvents(context) **New**: initWithContext(searchSettings) with proper typing | ||
|
|
Inject the ISW element into a theme search dialog. Waits for the ISW root element and the predictive-search container inside the dialog to be available, then inserts ISW immediately after the predictive-search container and sizes the dialog to fit. | |
|
|
Move the ISW element back to Restores dialog dimensions and resets wrapper position styles so that subsequent dropdown-style positioning calculations start from a clean state. | |
|
|
Navigate down in suggestions. | |
|
|
Navigate up in suggestions. | |
|
|
Open dropdown style. | |
|
|
Open full-width style overlay. | |
|
Open suggestion dropdown/overlay. **Legacy**: openSuggestion() / onOpenSuggestion() **New**: openSuggestion(input) with state management | ||
|
|
Perform the actual close operation. Separated from closeSuggestion to support deferred close (e.g., Symmetry theme delay). | |
|
|
Process suggestion data before passing it to the template renderer. Extension point for TS teams to modify, filter, or augment suggestion data immediately before rendering — without overriding the entire | |
|
|
Remove current selection. | |
|
Render suggestion data. **Legacy**: replaceHTML() + render logic in handleInstantSearchWidget **New**: render(data) with concurrent render prevention | ||
|
|
Render a 3rd-party support CRM button inside the ISW container. | |
|
|
Render default data. | |
|
|
Replace a block in the container. | |
|
|
Replace HTML in ISW container. **Legacy**: replaceHTML(context, htmlString) **New**: replaceHTML(htmlString) method | |
|
|
Restore saved focus element. | |
|
|
Save clicked suggestion term to localStorage for AIML analytics. The collection-filter module reads this value to attach **Legacy**: setLocalStorage(CLICK_SUGGESTION_TERM, title) in render callback **New**: Dedicated method for extensibility and testability | |
|
|
Save focus element for restoration. | |
|
|
Search and render results. | |
|
Setup accessibility attributes. **Legacy**: Inline in initInstantSearchWidgetEvents() **New**: Dedicated method for WCAG compliance | ||
|
|
Setup all event listeners: global (document click, resize) + custom window events. All handlers are stored in | |
|
|
Setup form buttons (submit, reset, close). | |
|
|
Setup global event listeners. | |
|
|
Setup input element attributes. | |
|
|
Setup click handlers on suggestion items. | |
|
|
Strip HTML tags from string. | |
|
|
Sync value across all search inputs. | |
|
|
Toggle reset button visibility. | |
|
Toggle suggestion visibility. | ||
|
|
Update ISW dropdown position for a given input. Convenience method wrapping the PositionService.updatePosition flow. Manages scroll handler cleanup automatically. **Legacy**: calcPositionSuggestionResult(context, input) **New**: updatePosition(input) with lifecycle management | |
|
|
Update selection state and UI. | |
|
|
Await full initialization, but never block a user click indefinitely. Resolves when resolves, or after a short timeout if init has stalled — matching the legacy behavior where a click simply no-ops rather than hanging. |