MCPcopy Create free account
hub / github.com/UI5/webcomponents / _listSelectionChange

Method _listSelectionChange

packages/main/src/MultiComboBox.ts:1625–1684  ·  view source on GitHub ↗
(e: CustomEvent<ListSelectionChangeEventDetail>)

Source from the content-addressed store, hash-verified

1623 }
1624
1625 _listSelectionChange(e: CustomEvent<ListSelectionChangeEventDetail>) {
1626 let changePrevented;
1627
1628 if (this.readonly) {
1629 e.preventDefault();
1630 return;
1631 }
1632
1633 if (!isPhone()) {
1634 this._previouslySelectedItems = e.detail.previouslySelectedItems;
1635 }
1636
1637 // don't call selection change right after selection as user can cancel it on phone
1638 if (!isPhone()) {
1639 if (this.selectedValues) {
1640 // Get values from all selected items (not just filtered ones)
1641 this.selectedValues = this._getItems()
1642 .filter((i): i is MultiComboBoxItem => isInstanceOfMultiComboBoxItem(i) && i.selected)
1643 .map(i => i.value)
1644 .filter((v): v is string => !!v);
1645 }
1646
1647 changePrevented = this.fireSelectionChange();
1648
1649 if (changePrevented) {
1650 e.preventDefault();
1651 this._revertSelection();
1652 }
1653 }
1654
1655 // casted to KeyboardEvent since isSpace and isSpaceCtrl accepts KeyboardEvent only
1656 const castedEvent = { key: e.detail.key } as KeyboardEvent;
1657
1658 if (!e.detail.selectedItems.length && this.filterSelected) {
1659 this.filterSelected = false;
1660 }
1661
1662 if (this.valueState === ValueState.Negative) {
1663 this._updateValueState(this._effectiveValueState);
1664 }
1665
1666 if (!e.detail.selectionComponentPressed && !isSpace(castedEvent) && !isSpaceCtrl(castedEvent)) {
1667 this.open = false;
1668 this.value = "";
1669
1670 // if the item (not checkbox) is clicked, call the selection change
1671 if (isPhone()) {
1672 changePrevented = this.fireSelectionChange();
1673 if (changePrevented) {
1674 e.preventDefault();
1675 this._revertSelection();
1676 }
1677 }
1678
1679 this.fireDecoratorEvent("input");
1680 return;
1681 }
1682

Callers

nothing calls this directly

Calls 7

_getItemsMethod · 0.95
fireSelectionChangeMethod · 0.95
_revertSelectionMethod · 0.95
_updateValueStateMethod · 0.95
isPhoneFunction · 0.85
isSpaceFunction · 0.85
isSpaceCtrlFunction · 0.85

Tested by

no test coverage detected