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

Method onBeforeRendering

packages/main/src/MultiComboBox.ts:1851–1903  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1849 }
1850
1851 onBeforeRendering() {
1852 const input = this._innerInput;
1853 const autoCompletedChars = input && (input.selectionEnd || 0) - (input.selectionStart || 0);
1854 const value = input && input.value;
1855
1856 if (this.open) {
1857 const list = this._getList();
1858 const selectedListItemsCount = this.items.filter(item => item.selected).length;
1859 this._allSelected = selectedListItemsCount > 0 && ((selectedListItemsCount === this.items.length) || (list?.getSlottedNodes("items").length === selectedListItemsCount));
1860 }
1861
1862 this._effectiveShowClearIcon = (this.showClearIcon && !!this.value && !this.readonly && !this.disabled);
1863
1864 if (input && !input.value) {
1865 this.valueBeforeAutoComplete = "";
1866 this._filteredItems = this._getItems();
1867 }
1868
1869 if (this.selectedValues) {
1870 this._syncSelection();
1871 }
1872
1873 this.tokenizerAvailable = this._getSelectedItems().length > 0;
1874 this.style.setProperty("--_ui5-input-icons-count", `${this.iconsCount}`);
1875
1876 if (!input || !value) {
1877 this._getItems().forEach(item => {
1878 if (isInstanceOfMultiComboBoxItem(item)) {
1879 item._isVisible = true;
1880 item._readonly = this.readonly;
1881 }
1882 });
1883 return;
1884 }
1885 // Typehead causes issues on Android devices, so we disable it for now
1886 // If there is already a selection the autocomplete has already been performed
1887 if (this._shouldAutocomplete && !isAndroid()) {
1888 const item = this._getFirstMatchingItem(value);
1889
1890 // Prevent typeahead during composition to avoid interfering with the composition process
1891 if (!this._isComposing && item) {
1892 // Keep the original typed in text intact
1893 this.valueBeforeAutoComplete = value;
1894 this._handleTypeAhead(item, value);
1895 }
1896 }
1897
1898 if (this._shouldFilterItems) {
1899 this._filteredItems = this._filterItems(autoCompletedChars ? this.valueBeforeAutoComplete : value);
1900 } else {
1901 this._filteredItems = this._getItems();
1902 }
1903 }
1904
1905 onAfterRendering() {
1906 this._getList();

Callers

nothing calls this directly

Calls 8

_getListMethod · 0.95
_getItemsMethod · 0.95
_syncSelectionMethod · 0.95
_getSelectedItemsMethod · 0.95
_getFirstMatchingItemMethod · 0.95
_handleTypeAheadMethod · 0.95
_filterItemsMethod · 0.95
isAndroidFunction · 0.85

Tested by

no test coverage detected