Reference Source
import Search from 'flarum/forum/components/Search'
public class | source

Search

Extends:

src/common/Component.js~Component → Search

The Search component displays a menu of as-you-type results from a variety of sources.

The search box will be 'activated' if the app's search state's getInitialSearch() value is a truthy value. If this is the case, an 'x' button will be shown next to the search field, and clicking it will clear the search.

ATTRS:

  • state: SearchState instance.

Static Member Summary

Static Public Members
public static

Member Summary

Public Members
public

Whether or not the search input has focus.

public

index: *

The index of the currently-selected

  • in the results list.
  • public

    The number of sources that are still loading results.

    public
    public

    sources: *

    public

    state: *

    public

    Method Summary

    Public Methods
    public

    clear()

    Clear the search

    public

    Get the position of the currently selected search result item.

    public

    getItem(index: *): *

    Get the

  • in the search results with the given index (numeric or named).
  • public

    oncreate(vnode: *)

    public

    oninit(vnode: *)

    public

    onremove(vnode: *)

    public

    onupdate(vnode: *)

    public

    Navigate to the currently selected search result and close the list.

    public

    Get all of the search result items that are selectable.

    public

    setIndex(index: *, scrollToItem: boolean)

    Set the currently-selected search result item to the one with the given index.

    public

    Build an item list of SearchSources.

    public
    public

    view(): *

    Static Public Members

    public static MIN_SEARCH_LEN: * source

    Public Members

    public hasFocus: * source

    Whether or not the search input has focus.

    public index: * source

    The index of the currently-selected

  • in the results list. This can be a unique string (to account for the fact that an item's position may jump around as new results load), but otherwise it will be numeric (the sequential position within the list).
  • public loadingSources: * source

    The number of sources that are still loading results.

    public navigator: * source

    public sources: * source

    public state: * source

    public updateMaxHeightHandler: * source

    Public Methods

    public clear() source

    Clear the search

    public getCurrentNumericIndex(): * source

    Get the position of the currently selected search result item.

    Return:

    *

    public getItem(index: *): * source

    Get the

  • in the search results with the given index (numeric or named).
  • Params:

    NameTypeAttributeDescription
    index *

    Return:

    *

    public oncreate(vnode: *) source

    Params:

    NameTypeAttributeDescription
    vnode *

    public oninit(vnode: *) source

    Params:

    NameTypeAttributeDescription
    vnode *

    public onremove(vnode: *) source

    Params:

    NameTypeAttributeDescription
    vnode *

    public onupdate(vnode: *) source

    Params:

    NameTypeAttributeDescription
    vnode *

    public selectResult() source

    Navigate to the currently selected search result and close the list.

    public selectableItems(): * source

    Get all of the search result items that are selectable.

    Return:

    *

    public setIndex(index: *, scrollToItem: boolean) source

    Set the currently-selected search result item to the one with the given index.

    Params:

    NameTypeAttributeDescription
    index *
    scrollToItem boolean
    • optional
    • default: false

    public sourceItems(): * source

    Build an item list of SearchSources.

    Return:

    *

    public updateMaxHeight() source

    public view(): * source

    Return:

    *