Skip to content

@serenity-is/corelib / MultiSelect2

Class: MultiSelect2

Defined in: src/ui/editors/select2.tsx:3337

Extends

Constructors

Constructor

new MultiSelect2(): MultiSelect2

Returns

MultiSelect2

Inherited from

AbstractSelect2.constructor

Properties

_touchEvent

protected _touchEvent: boolean

Defined in: src/ui/editors/select2.tsx:1213

Whether the results were touched, when the click that follows selects what is highlighted, see handleDropdownClick.

Inherited from

AbstractSelect2._touchEvent


autofocus

protected autofocus: boolean

Defined in: src/ui/editors/select2.tsx:1216

Inherited from

AbstractSelect2.autofocus


container

container: HTMLElement

Defined in: src/ui/editors/select2.tsx:1217

Inherited from

AbstractSelect2.container


containerEventName

protected containerEventName: string

Defined in: src/ui/editors/select2.tsx:1219

Inherited from

AbstractSelect2.containerEventName


containerId

protected containerId: string

Defined in: src/ui/editors/select2.tsx:1218

Inherited from

AbstractSelect2.containerId


context

protected context: any

Defined in: src/ui/editors/select2.tsx:1220

Inherited from

AbstractSelect2.context


dropdown: HTMLElement

Defined in: src/ui/editors/select2.tsx:1221

Inherited from

AbstractSelect2.dropdown


elementTabIndex

protected elementTabIndex: string

Defined in: src/ui/editors/select2.tsx:1222

Inherited from

AbstractSelect2.elementTabIndex


enabledInterface

protected enabledInterface: boolean

Defined in: src/ui/editors/select2.tsx:1223

Inherited from

AbstractSelect2.enabledInterface


focusser

protected focusser: HTMLInputElement

Defined in: src/ui/editors/select2.tsx:3347

The input that has the focus of a checklist while it is closed, see Select2Options.checkList.


highlightNavigated

protected highlightNavigated: boolean

Defined in: src/ui/editors/select2.tsx:2214

Whether the highlight was moved with the arrow keys since the dropdown was opened, see tabSelects.

Inherited from

AbstractSelect2.highlightNavigated


id()

protected id: (item) => string

Defined in: src/ui/editors/select2.tsx:1224

Parameters

item

any

Returns

string

Inherited from

AbstractSelect2.id


nextSearchTerm

protected nextSearchTerm: string

Defined in: src/ui/editors/select2.tsx:1225

Inherited from

AbstractSelect2.nextSearchTerm


opts

protected opts: Select2Options

Defined in: src/ui/editors/select2.tsx:1226

Inherited from

AbstractSelect2.opts


propertyObserver

protected propertyObserver: MutationObserver

Defined in: src/ui/editors/select2.tsx:1227

Inherited from

AbstractSelect2.propertyObserver


queryCount

protected queryCount: number

Defined in: src/ui/editors/select2.tsx:1228

Inherited from

AbstractSelect2.queryCount


results

protected results: HTMLElement

Defined in: src/ui/editors/select2.tsx:1229

Inherited from

AbstractSelect2.results


resultsPage

protected resultsPage: number

Defined in: src/ui/editors/select2.tsx:1230

Inherited from

AbstractSelect2.resultsPage


search: HTMLInputElement

Defined in: src/ui/editors/select2.tsx:1231

Inherited from

AbstractSelect2.search


select

protected select: HTMLSelectElement

Defined in: src/ui/editors/select2.tsx:1475

Inherited from

AbstractSelect2.select


selection

protected selection: HTMLElement

Defined in: src/ui/editors/select2.tsx:1232

Inherited from

AbstractSelect2.selection


showSearchInput

protected showSearchInput: boolean

Defined in: src/ui/editors/select2.tsx:1233

Inherited from

AbstractSelect2.showSearchInput

Methods

addSelectedChoice()

protected addSelectedChoice(data): void

Defined in: src/ui/editors/select2.tsx:4199

Parameters

data

Select2Item

Returns

void


blur()

protected blur(): void

Defined in: src/ui/editors/select2.tsx:2628

Returns

void

Inherited from

AbstractSelect2.blur


buildChangeDetails()

protected buildChangeDetails(old, current): object

Defined in: src/ui/editors/select2.tsx:4659

Parameters

old

Select2Item[]

current

Select2Item[]

Returns

object

added

added: Select2Item[] = currentCopy

removed

removed: Select2Item[] = oldCopy


cancel()

protected cancel(e?): void

Defined in: src/ui/editors/select2.tsx:4192

Parameters

e?

Event

Returns

void

Overrides

AbstractSelect2.cancel


clearCheckList()

protected clearCheckList(): void

Defined in: src/ui/editors/select2.tsx:3878

Clears the selection of a checklist, as its clear button does.

Returns

void


clearDropdownAlignmentPreference()

protected clearDropdownAlignmentPreference(): void

Defined in: src/ui/editors/select2.tsx:1966

Returns

void

Inherited from

AbstractSelect2.clearDropdownAlignmentPreference


clearPlaceholder()

protected clearPlaceholder(): void

Defined in: src/ui/editors/select2.tsx:3950

Returns

void


clearSearch()

protected clearSearch(): void

Defined in: src/ui/editors/select2.tsx:3920

Returns

void

Overrides

AbstractSelect2.clearSearch


clearTouchMoved()

protected clearTouchMoved(): void

Defined in: src/ui/editors/select2.tsx:2293

Returns

void

Inherited from

AbstractSelect2.clearTouchMoved


close()

close(): void

Defined in: src/ui/editors/select2.tsx:4025

Returns

void

Overrides

AbstractSelect2.close


countSelectableResults()

protected countSelectableResults(): number

Defined in: src/ui/editors/select2.tsx:2297

Returns

number

Inherited from

AbstractSelect2.countSelectableResults


createContainer()

protected createContainer(): HTMLElement

Defined in: src/ui/editors/select2.tsx:3349

Returns

HTMLElement

Overrides

AbstractSelect2.createContainer


data()

Call Signature

data(): Select2Item[]

Defined in: src/ui/editors/select2.tsx:4759

Returns

Select2Item[]

Overrides

AbstractSelect2.data

Call Signature

data(values, triggerChange?): void

Defined in: src/ui/editors/select2.tsx:4760

Parameters
values

Select2Item[]

triggerChange?

boolean

Returns

void

Overrides

AbstractSelect2.data


destroy()

destroy(): void

Defined in: src/ui/editors/select2.tsx:3462

Returns

void

Overrides

AbstractSelect2.destroy


disable()

disable(): void

Defined in: src/ui/editors/select2.tsx:1807

Returns

void

Inherited from

AbstractSelect2.disable


enable()

enable(enabled?): void

Defined in: src/ui/editors/select2.tsx:1798

Parameters

enabled?

boolean

Returns

void

Inherited from

AbstractSelect2.enable


enableInterface()

protected enableInterface(): boolean

Defined in: src/ui/editors/select2.tsx:3888

Returns

boolean

Overrides

AbstractSelect2.enableInterface


ensureHighlightVisible()

protected ensureHighlightVisible(): void

Defined in: src/ui/editors/select2.tsx:2162

Returns

void

Inherited from

AbstractSelect2.ensureHighlightVisible


externalSearch()

protected externalSearch(term): void

Defined in: src/ui/editors/select2.tsx:2130

Opens control, sets input value, and updates results.

Parameters

term

string

Returns

void

Inherited from

AbstractSelect2.externalSearch


findHighlightableChoices()

protected findHighlightableChoices(): Element[]

Defined in: src/ui/editors/select2.tsx:4532

The results that can be highlighted: a checklist keeps the ones that are selected, which a click toggles.

Returns

Element[]

Overrides

AbstractSelect2.findHighlightableChoices


focus()

focus(): void

Defined in: src/ui/editors/select2.tsx:4043

Returns

void

Overrides

AbstractSelect2.focus


focusSearch()

protected focusSearch(): void

Defined in: src/ui/editors/select2.tsx:2640

Returns

void

Inherited from

AbstractSelect2.focusSearch


getMaximumSelectionSize()

protected getMaximumSelectionSize(): any

Defined in: src/ui/editors/select2.tsx:2158

Returns

any

Inherited from

AbstractSelect2.getMaximumSelectionSize


getMaxSearchWidth()

protected getMaxSearchWidth(): number

Defined in: src/ui/editors/select2.tsx:4618

Returns

number


getPlaceholder()

protected getPlaceholder(): string

Defined in: src/ui/editors/select2.tsx:2661

Returns

string

Inherited from

AbstractSelect2.getPlaceholder


getPlaceholderOption()

protected getPlaceholderOption(): HTMLOptionElement

Defined in: src/ui/editors/select2.tsx:2676

Returns

HTMLOptionElement

Inherited from

AbstractSelect2.getPlaceholderOption


getVal()

protected getVal(): string[]

Defined in: src/ui/editors/select2.tsx:4632

Returns

string[]


handleDropdownMouseUp()

protected handleDropdownMouseUp(e): void

Defined in: src/ui/editors/select2.tsx:4539

Parameters

e

Event

Returns

void

Overrides

AbstractSelect2.handleDropdownMouseUp


handleEnter()

protected handleEnter(): void

Defined in: src/ui/editors/select2.tsx:4483

Enter accepts the selection of a checklist, which Space and clicks make, and closes it.

Returns

void

Overrides

AbstractSelect2.handleEnter


handleRemoveKey()

protected handleRemoveKey(key): boolean

Defined in: src/ui/editors/select2.tsx:3857

Handles Backspace and Delete on a checklist, which has no choice for each item to remove one by one: Backspace unticks the last item that was ticked, and Delete clears them all, as the clear button does, when the select allows it, see Select2Options.allowClear.

Parameters

key

string

The key.

Returns

boolean

True when the key was handled.


handleSearchBlur()

protected handleSearchBlur(): void

Defined in: src/ui/editors/select2.tsx:2386

Returns

void

Inherited from

AbstractSelect2.handleSearchBlur


handleSearchFocus()

protected handleSearchFocus(): void

Defined in: src/ui/editors/select2.tsx:2382

Returns

void

Inherited from

AbstractSelect2.handleSearchFocus


handleSearchInput()

protected handleSearchInput(): void

Defined in: src/ui/editors/select2.tsx:2378

Returns

void

Inherited from

AbstractSelect2.handleSearchInput


handleSpace()

protected handleSpace(): boolean

Defined in: src/ui/editors/select2.tsx:4474

Space ticks, or unticks, the highlighted result of a checklist, as for a check box, and is typed in the search when no result is highlighted, which is the case after something is typed, see postprocessResults, so that a space can still be searched for after a word, e.g. "Dairy Products". It is the same whether the search input has the focus or not, e.g. on a touch device with a hardware keyboard, where it does not get the focus on opening.

Returns

boolean

Overrides

AbstractSelect2.handleSpace


highlight()

protected highlight(index?): number

Defined in: src/ui/editors/select2.tsx:2257

Parameters

index?

number

Returns

number

Inherited from

AbstractSelect2.highlight


highlightUnderEvent()

protected highlightUnderEvent(event): void

Defined in: src/ui/editors/select2.tsx:2301

Parameters

event

Event

Returns

void

Inherited from

AbstractSelect2.highlightUnderEvent


init()

init(opts): void

Defined in: src/ui/editors/select2.tsx:1279

Parameters

opts

Select2Options

Returns

void

Inherited from

AbstractSelect2.init


initContainer()

protected initContainer(): void

Defined in: src/ui/editors/select2.tsx:3480

Returns

void

Overrides

AbstractSelect2.initContainer


initContainerWidth()

protected initContainerWidth(): void

Defined in: src/ui/editors/select2.tsx:2696

Get the desired width for the container element. This is derived first from option width passed to select2, then the inline 'style' on the original element, and finally falls back to the jQuery calculated element width.

Returns

void

Inherited from

AbstractSelect2.initContainerWidth


initSelection()

protected initSelection(): void

Defined in: src/ui/editors/select2.tsx:3898

Returns

void

Overrides

AbstractSelect2.initSelection


isChecklist()

protected isChecklist(): boolean

Defined in: src/ui/editors/select2.tsx:4527

Whether the selection is a checklist, which keeps the selected results in the list, and toggles them, see Select2Options.checkList.

Returns

boolean


isFocused()

isFocused(): boolean

Defined in: src/ui/editors/select2.tsx:4048

Returns

boolean

Overrides

AbstractSelect2.isFocused


isInterfaceEnabled()

protected isInterfaceEnabled(): boolean

Defined in: src/ui/editors/select2.tsx:1781

Returns

boolean

Inherited from

AbstractSelect2.isInterfaceEnabled


isSelectAllItem()

protected isSelectAllItem(item): boolean

Defined in: src/ui/editors/select2.tsx:4447

Whether an item is the one that selects all the results that are shown, or clears them, which the select adds itself, see Select2Options.selectAll. Only a multiple select has one.

Parameters

item

Select2Item

Returns

boolean

Overrides

AbstractSelect2.isSelectAllItem


loadMoreIfNeeded()

protected loadMoreIfNeeded(): void

Defined in: src/ui/editors/select2.tsx:2312

Returns

void

Inherited from

AbstractSelect2.loadMoreIfNeeded


monitorSource()

protected monitorSource(): void

Defined in: src/ui/editors/select2.tsx:1730

Monitor the original element for changes and update select2 accordingly

Returns

void

Inherited from

AbstractSelect2.monitorSource


moveHighlight()

protected moveHighlight(delta): void

Defined in: src/ui/editors/select2.tsx:4490

Parameters

delta

number

Returns

void

Overrides

AbstractSelect2.moveHighlight


onSelect()

protected onSelect(data, options): void

Defined in: src/ui/editors/select2.tsx:4116

Parameters

data

Select2Item

options

any

Returns

void

Overrides

AbstractSelect2.onSelect


onSortEnd()

protected onSortEnd(): void

Defined in: src/ui/editors/select2.tsx:4738

Returns

void


onSortStart()

protected onSortStart(): void

Defined in: src/ui/editors/select2.tsx:4727

Returns

void


open()

open(): boolean

Defined in: src/ui/editors/select2.tsx:1978

Opens the dropdown

Returns

boolean

whether or not dropdown was opened. This method will return false if, for example, the dropdown is already open, or if the 'open' event listener on the element called preventDefault().

Inherited from

AbstractSelect2.open


opened()

opened(): boolean

Defined in: src/ui/editors/select2.tsx:1820

Returns

boolean

Inherited from

AbstractSelect2.opened


opening()

protected opening(): void

Defined in: src/ui/editors/select2.tsx:3957

Returns

void

Overrides

AbstractSelect2.opening


optionToData()

optionToData(element): Select2Item

Defined in: src/ui/editors/select2.tsx:1455

Parameters

element

HTMLOptGroupElement | HTMLOptionElement

Returns

Select2Item

Inherited from

AbstractSelect2.optionToData


positionDropdown()

positionDropdown(): void

Defined in: src/ui/editors/select2.tsx:1824

Returns

void

Inherited from

AbstractSelect2.positionDropdown


postprocessResults()

protected postprocessResults(data?, initial?, noHighlightUpdate?): void

Defined in: src/ui/editors/select2.tsx:4314

Parameters

data?

Select2Result

initial?

boolean

noHighlightUpdate?

boolean

Returns

void

Overrides

AbstractSelect2.postprocessResults


prepareOpts()

protected prepareOpts(opts): Select2Options

Defined in: src/ui/editors/select2.tsx:3389

Parameters

opts

Select2Options

Returns

Select2Options

Overrides

AbstractSelect2.prepareOpts


readonly()

readonly(enabled?): void

Defined in: src/ui/editors/select2.tsx:1811

Parameters

enabled?

boolean

Returns

void

Inherited from

AbstractSelect2.readonly


removeHighlight()

protected removeHighlight(): void

Defined in: src/ui/editors/select2.tsx:2285

Returns

void

Inherited from

AbstractSelect2.removeHighlight


resizeSearch()

protected resizeSearch(): void

Defined in: src/ui/editors/select2.tsx:4628

Sizes the search field of the choices, which the styles do: it takes the rest of the line after the choices, and goes to a line of its own when too little is left. It used to be given a width in pixels, from the text typed and the width of the container, which made a container whose width is not set, e.g. in a grid of fields, grow as the user typed, so any width it has is removed.

Returns

void


selectChoice()

protected selectChoice(choice): void

Defined in: src/ui/editors/select2.tsx:3444

Parameters

choice

HTMLElement

Returns

void


selectHighlighted()

protected selectHighlighted(options?): void

Defined in: src/ui/editors/select2.tsx:2644

Parameters

options?

any

Returns

void

Inherited from

AbstractSelect2.selectHighlighted


setVal()

protected setVal(val): void

Defined in: src/ui/editors/select2.tsx:4643

Parameters

val

string[]

Returns

void


shouldOpen()

protected shouldOpen(): boolean

Defined in: src/ui/editors/select2.tsx:1956

Returns

boolean

Inherited from

AbstractSelect2.shouldOpen


showSearch()

protected showSearch(showSearchInput): void

Defined in: src/ui/editors/select2.tsx:2146

Shows or hides the search box of the dropdown, which stays focusable when it is hidden, so that the keys still reach the results. Only a select that has its search box in the dropdown has one, e.g. a single select, or a checklist, see Select2Options.checkList.

Parameters

showSearchInput

boolean

Whether to show the search box.

Returns

void

Inherited from

AbstractSelect2.showSearch


tabOut()

protected tabOut(e, from): void

Defined in: src/ui/editors/select2.tsx:2233

Leaves the control with Tab, or Shift+Tab, from its dropdown: closes it, which the select does before, and moves the focus to the next element, or the previous one, from the control, as the search input is in the dropdown, at the end of the page, from which the browser would move it.

Parameters

e

KeyboardEvent

The key event.

from

HTMLElement

The element of the control that takes the focus, from which the focus moves.

Returns

void

Inherited from

AbstractSelect2.tabOut


tabSelects()

protected tabSelects(): boolean

Defined in: src/ui/editors/select2.tsx:2222

Whether Tab selects the highlighted result as it leaves the control: only when the user pointed at it, by typing a search, which highlights a result that is found, or by moving the highlight with the arrow keys, so that opening the dropdown and leaving it with Tab does not change the value to the result that happens to be highlighted. The mouse does not count, as it often rests over the results by chance.

Returns

boolean

Inherited from

AbstractSelect2.tabSelects


tokenize()

protected tokenize(): string

Defined in: src/ui/editors/select2.tsx:4104

Default tokenizer function which does nothing

Returns

string

Overrides

AbstractSelect2.tokenize


touchMoved()

protected touchMoved(): void

Defined in: src/ui/editors/select2.tsx:2289

Returns

void

Inherited from

AbstractSelect2.touchMoved


triggerChange()

protected triggerChange(details?): void

Defined in: src/ui/editors/select2.tsx:1762

Triggers the change event on the source element

Parameters

details?

any

Returns

void

Inherited from

AbstractSelect2.triggerChange


triggerSelect()

protected triggerSelect(data): boolean

Defined in: src/ui/editors/select2.tsx:1753

Parameters

data

Select2Item

Returns

boolean

Inherited from

AbstractSelect2.triggerSelect


unselect()

protected unselect(selected): boolean

Defined in: src/ui/editors/select2.tsx:4276

Parameters

selected

HTMLElement

Returns

boolean


unselectById()

protected unselectById(id): void

Defined in: src/ui/editors/select2.tsx:4552

Unselects an item by its id, e.g. when the row of a checklist that is checked is clicked again.

Parameters

id

string

Returns

void


updateResults()

protected updateResults(initial?): void

Defined in: src/ui/editors/select2.tsx:2454

Parameters

initial?

boolean

whether or not this is the call to this method right after the dropdown has been opened

Returns

void

Inherited from

AbstractSelect2.updateResults


updateSelection()

protected updateSelection(data): void

Defined in: src/ui/editors/select2.tsx:4055

Parameters

data

Select2Item[]

Returns

void


val()

val(val?, triggerChange?): string[]

Defined in: src/ui/editors/select2.tsx:4680

Parameters

val?

string[]

triggerChange?

boolean

Returns

string[]

Overrides

AbstractSelect2.val


withSelectAllItem()

protected withSelectAllItem(results, more?): Select2Item[]

Defined in: src/ui/editors/select2.tsx:4452

Returns the first page of results with the item that selects them all, when the select has one, see Select2Options.selectAll. The results are not changed.

Parameters

results

Select2Item[]

The first page of results.

more?

boolean

Returns

Select2Item[]

Overrides

AbstractSelect2.withSelectAllItem