Support Menu

Coveo component Tab

The Tab component renders a bar 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.

Including and Excluding Other HTML Components:

You can hide or show a specific HTML component based on the currently selected Tab by adding one of the following attributes to its tag:

  • <div data-tab="foobar">: Only include this element in the Tab with foobar as its data-id.
  • <div data-tab-not="foobar">: Do not include this element in the Tab with foobar as its data-id.
  • <div data-tab="foobar,somethingelse">: Only include this element in the Tab with foobar as its data-id and in the Tab with somethingelse as its data-id.

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

Component Options

caption

caption: string

Specifies the caption of the Tab.

Specifying a value for this option is necessary for this 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.

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

Specifies whether to filter duplicates in the search results when the user selects the Tab.

Setting this option to true forces duplicates to not appear in the search results. However, Facet counts still include duplicates, which can be confusing for the end user. This is a limitation of the index.

Example:

The end user narrows a query down to one document that has a duplicate. If this options is true and the user selects the Tab, only one document appears in the search results while the Facet count is still 2.

Note:

It is also possible to enable duplicate filtering for the entire SearchInterface rather than for a single Tab (see SearchInterface.options.enableDuplicateFiltering).

Default value is 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.

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
deprecated

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

Specifies an icon to use for the Tab.

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.

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

layout

layout: string

Specifies the default layout to display when the user selects the Tab (see ResultList.options.layout and 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.

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

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 Query Parameters - 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 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'

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). Component 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 differents component. Mainly used by ResultLink.

componentStateModel

componentStateModel: ComponentStateModel

Contains the state of different component (enabled vs disabled). Allows to get/set values. Trigger 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.

usageAnalytics

usageAnalytics: IAnalyticsClient

A reference to the Analytics.client.

Static ID

ID: string

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

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