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

Method _adjustSelectionRange

packages/main/src/Input.ts:849–866  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

847 }
848
849 _adjustSelectionRange() {
850 const innerInput = this.getInputDOMRefSync()!;
851 const visibleItems = this.Suggestions?._getItems().filter(item => !item.hidden) as IInputSuggestionItemSelectable[];
852 const currentItem = visibleItems?.find(item => { return item.selected || item.focused; });
853 const groupItems = this._flattenItems.filter(item => this._isGroupItem(item));
854
855 if (currentItem && !groupItems.includes(currentItem)) {
856 const doesItemStartWithTypedValue = currentItem?.text?.toLowerCase().startsWith(this.typedInValue.toLowerCase());
857 if (doesItemStartWithTypedValue) {
858 innerInput.setSelectionRange(this.typedInValue.length, this.value.length);
859 } else {
860 innerInput.setSelectionRange(0, this.value.length);
861 }
862 } else {
863 // No current item selected (e.g., during typing) - use default typeahead selection
864 innerInput.setSelectionRange(this.typedInValue.length, this.value.length);
865 }
866 }
867
868 _onkeydown(e: KeyboardEvent) {
869 this._isKeyNavigation = true;

Callers 1

onAfterRenderingMethod · 0.95

Calls 3

getInputDOMRefSyncMethod · 0.95
_isGroupItemMethod · 0.95
_getItemsMethod · 0.45

Tested by

no test coverage detected