Coveo Tab Component (CoveoTab)

The Tab component renders a widget that allows the end user to select a specific search interface.

This component attaches itself to a div element. It is in charge of adding an advanced expression to the outgoing query in order to refine the results.

The Tab component can also hide and show different parts of the UI. For each individual component in the UI, you can specify whether you wish to include or exclude that component when the user selects a certain Tab (see Using Components Only on Specific Tabs).

Setting a New Endpoint for a Tab:

A Tab can use a custom endpoint when performing a query. Of course, you need to make sure that the endpoint exists in the array of Coveo.SearchEndpoint.endpoints (see SearchEndpoint.endpoints).

Coveo.SearchEndpoint.endpoints["specialEndpoint"] = new Coveo.SearchEndpoint({
    restUri : 'https://somewhere.com/rest/search'
})

[ ... ]

<div class='CoveoTab' data-endpoint='specialEndpoint'></div>

Index

Methods

debugInfo

  • debugInfo(): any

disable

  • disable(): void
  • Disable the component. Normally this means that the component will not execute handlers for the framework events (query events, for example). Components are enabled by default on creation.

    Returns void

enable

  • enable(): void
  • Enable the component. Normally this means that the component will execute handlers for the framework events (query events, for example). Components are enabled by default on creation.

    Returns void

getBindings

isElementIncludedInTab

  • isElementIncludedInTab(element: HTMLElement): boolean
  • Indicates whether the HTMLElement argument is included in the Tab. Included elements are shown when the Tab is selected, whereas excluded elements are not.

    Parameters

    • element: HTMLElement

      The HTMLElement to verify.

    Returns boolean

    true if the HTMLElement is included in the Tab; false if it is excluded.

select

  • select(): void
  • Selects the current Tab.

    Also logs the interfaceChange event in the usage analytics with the new current Tab.options.id as metada and triggers a new query.

    Returns void

Static get

  • get(element: HTMLElement, componentClass?: any, noThrow?: boolean): BaseComponent
  • Get the bound component to the given HTMLElement. Throws an assert if the HTMLElement has no component bound, unless using the noThrow argument.
    If there is multiple component bound to the current HTMLElement, you must specify the component class.

    Parameters

    • element: HTMLElement

      HTMLElement for which to get the bound component.

    • Optional componentClass: any

      Optional component class. If the HTMLElement has multiple components bound, you must specify which one you are targeting.

    • Optional noThrow: boolean

      Boolean option to tell the method to not throw on error.

    Returns BaseComponent

Properties

bind

Allows the component to bind events and execute them only when it is enabled.

type

{Coveo.ComponentEvents}

componentOptionsModel

componentOptionsModel: ComponentOptionsModel

Contains the state of options for different components. Mainly used by ResultLink.

componentStateModel

componentStateModel: ComponentStateModel

Contains the state of different components (enabled vs disabled). Allows to get/set values. Triggers component state event when modified. Each component can listen to those events.

disabled

disabled: boolean

A disabled component will not participate in the query, or listen to ComponentEvents.

type

{boolean}

logger

logger: Logger

Allows component to log in the dev console.

queryController

queryController: QueryController

Contains the singleton that allows to trigger queries.

queryStateModel

queryStateModel: QueryStateModel

Contains the state of the query. Allows to get/set values. Trigger query state event when modified. Each component can listen to those events.

root

root: HTMLElement

A reference to the root HTMLElement (the SearchInterface).

searchInterface

searchInterface: SearchInterface

A reference to the root of every component, the SearchInterface.

Static ID

ID: string

The static ID that each component needs in order to be identified.
For example, SearchButton -> static ID: SearchButton -> className: CoveoSearchButton

Accessors

usageAnalytics

Component Options

caption

caption: string

Specifies the caption of the Tab.

Specifying a value for this option is necessary for this component to work.

Required

Specifying a value for this option is required for the component to work

Markup configuration example(s) :
data-caption='foo'

constant

constant: boolean

Specifies whether to include the Tab.options.expression in the constant part of the query.

The index specially optimizes the constant part of the query to execute faster. However, you must be careful not to include dynamic query expressions, otherwise the cache will lose its efficiency.

Default value is true.

Default

true

Markup configuration example(s) :
data-constant='true'
data-constant='false'

dropdownHeaderLabel

dropdownHeaderLabel: string

Specifies the label of the button that allows to show the hidden tabs when in responsive mode.

If more than one Tab in the search interface specifies a value for this option, then the framework uses the first occurrence of the option.

The default value is "More".

Markup configuration example(s) :
data-dropdown-header-label='foo'

enableDuplicateFiltering

enableDuplicateFiltering: boolean

Whether to filter out duplicates, so that items resembling one another only appear once in the query results.

Notes:

  • Two items must be at least 85% similar to one another to be considered duplicates.
  • When a pair of duplicates is found, only the higher-ranked item of the two is kept in the result set.
  • Enabling this feature can make the total result count less precise, as only the requested page of query results is submitted to duplicate filtering.
  • The default value for this option can be modified through the SearchInterface component.
Default

false

Markup configuration example(s) :
data-enable-duplicate-filtering='true'
data-enable-duplicate-filtering='false'

enableResponsiveMode

enableResponsiveMode: boolean

Specifies whether to enable responsive mode for tabs. Responsive mode makes overflowing tabs disappear, instead making them available using a dropdown button. Responsive tabs are enabled either when tabs overflow or when the width of the search interface becomes too small.

Disabling responsive mode for one Tab also disables it for all tabs. Therefore, you only need to set this option to false on one Tab to disable responsive mode.

Default value is true.

Default

true

Available since

October 2016 Release (v1.1550.5)

Markup configuration example(s) :
data-enable-responsive-mode='true'
data-enable-responsive-mode='false'

endpoint

endpoint: SearchEndpoint

Specifies the SearchEndpoint to point to when performing queries from within the Tab.

By default, the Tab uses the "default" endpoint.

expression

expression: string

Specifies an advanced expression or filter that the Tab should add to any outgoing query.

Example:

@objecttype==Message

Default value is undefined and the Tab applies no additional expression or filter to the query.

Markup configuration example(s) :
data-expression='foo'

icon

icon: string

Specifies an icon to use for the Tab.

deprecated

This options is mostly kept for legacy reasons. If possible, you should avoid using it.

Markup configuration example(s) :
data-icon='foo'

id

id: string

Specifies a unique ID for the Tab.

Specifying a value for this option is necessary for this component to work.

Required

Specifying a value for this option is required for the component to work

Markup configuration example(s) :
data-id='foo'

layout

layout: "list" | "card" | "table"

Specifies the default layout to display when the user selects the Tab (see ResultList.options.layout and {@link ResultLayout}).

See the ValidLayout type for the list of possible values.

If not specified, it will default to 'list'.

See also Result Layouts.

Default value is undefined and the component selects the first available layout.

maximumAge

maximumAge: number

Specifies the maximum age (in milliseconds) that cached query results can have to still be usable as results instead of performing a new query on the index from within the Tab. The cache is located in the Coveo Search API (which resides between the index and the search interface).

If cached results that are older than the age you specify in this option are available, a new query will be performed on the index anyhow.

On high-volume public web sites, specifying a higher value for this option can greatly improve query response time at the cost of result freshness.

Note:

It is also possible to set a maximum cache age for the entire SearchInterface rather than for a single Tab (see SearchInterface.options.maximumAge).

Default value is undefined and the Coveo Search API determines the maximum cache age. This is typically equivalent to 30 minutes (see maximumAge).

Markup configuration example(s) :
data-maximum-age='10'

pipeline

pipeline: string

Specifies the name of the query pipeline to use for the queries when the Tab is selected.

You can specify a value for this option if your index is in a Coveo Cloud organization in which pipelines have been created (see Adding and Managing Query Pipelines).

Default value is undefined, which means that pipeline selection conditions defined in the Coveo Cloud organization apply.

Markup configuration example(s) :
data-pipeline='foo'

sort

sort: string

Specifies the default sort criteria to use when selecting the Tab. A Sort component with the same parameter needs to be present in the search interface in order for this option to function properly.

Examples:

  • data-sort='relevancy'
  • data-sort='date descending'

Default value is undefined and the normal Sort component behavior applies.

Markup configuration example(s) :
data-sort='foo'

Constructors

constructor

  • Creates a new Tab. Binds on buildingQuery event as well as an event on click of the element.

    Parameters

    • element: HTMLElement

      The HTMLElement on which to instantiate the component. Normally a div.

    • Optional options: ITabOptions

      The options for the Tab component.

    • Optional bindings: IComponentBindings

      The bindings that the component requires to function normally. If not set, these will be automatically resolved (with a slower execution time).

    Returns Tab