The StandaloneSearchBox headless controller offers a high-level interface for designing a common search box UI controller. Meant to be used for a search box that will redirect instead of executing a query.

Example: standalone-search-box.fn.tsx

interface StandaloneSearchBox {
    state: StandaloneSearchBoxState;
    afterRedirection(): void;
    clear(): void;
    selectSuggestion(value: string): void;
    showSuggestions(): void;
    submit(): void;
    subscribe(listener: () => void): Unsubscribe;
    updateRedirectUrl(url: string): void;
    updateText(value: string): void;
}

Hierarchy (View Summary)

Methods

  • Resets the standalone search box state. To be dispatched on single page applications after the redirection has been triggered.

    Returns void

  • 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

  • Triggers a redirection.

    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 redirection url of the standalone search box.

    Parameters

    • url: string

      The new URL to redirect to.

    Returns void

  • 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

A scoped and simplified part of the headless state that is relevant to the StandaloneSearchBox controller.