The SearchBox headless controller offers a high-level interface for designing a common search box UI controller with highlighting for query suggestions.

interface CoreSearchBox {
    state: SearchBoxState;
    clear(): void;
    selectSuggestion(value: string): void;
    showSuggestions(): void;
    submit(
        legacyAnalytics?: LegacySearchAction,
        nextAnalytics?: SearchAction,
    ): void;
    subscribe(listener: () => void): Unsubscribe;
    updateText(value: string): void;
}

Hierarchy (View Summary)

Methods

  • Clears the search box text and the suggestions.

    Returns void

  • Selects a suggestion and calls submit.

    Parameters

    • value: string

      The string value of the suggestion to select

    Returns void

  • Shows the suggestions for the current search box value.

    Returns void

  • Deselects all facets and triggers a search query.

    Parameters

    • OptionallegacyAnalytics: LegacySearchAction

      The legacy analytics action to log after submitting a query.

    • OptionalnextAnalytics: SearchAction

      The next analytics action to log after submitting a query.

    Returns void

  • Adds a callback that's invoked on state change.

    Parameters

    • listener: () => void

      A callback that's invoked on state change.

    Returns Unsubscribe

    A function to remove the listener.

  • Updates the search box text value and shows the suggestions for that value.

    Parameters

    • value: string

      The string value to update the search box with.

    Returns void

Properties

The state of the SearchBox controller.