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

Method _handleEnter

packages/main/src/Input.ts:1031–1065  ·  view source on GitHub ↗
(e: KeyboardEvent)

Source from the content-addressed store, hash-verified

1029 }
1030
1031 _handleEnter(e: KeyboardEvent) {
1032 // if a group item is focused, this is false
1033 const suggestionItemPressed = !!(this.Suggestions?.onEnter(e));
1034 const innerInput = this.getInputDOMRefSync()!;
1035
1036 let matchingItem = this._matchedSuggestionItem;
1037 if (!matchingItem) {
1038 matchingItem = this._selectableItems.find(item => {
1039 return item.text?.toLowerCase() === this.value.toLowerCase();
1040 });
1041 }
1042
1043 if (matchingItem) {
1044 const itemText = matchingItem.text || "";
1045
1046 innerInput.setSelectionRange(itemText.length, itemText.length);
1047 if (!suggestionItemPressed) {
1048 this.fireSelectionChange(matchingItem, true);
1049 this.acceptSuggestion(matchingItem, true);
1050 this.open = false;
1051 }
1052 }
1053
1054 if (this._isPhone && !this._flattenItems.length && !this.isTypeNumber) {
1055 innerInput.setSelectionRange(this.value.length, this.value.length);
1056 }
1057
1058 if (!suggestionItemPressed) {
1059 this.lastConfirmedValue = this.value;
1060
1061 return;
1062 }
1063
1064 this.focused = true;
1065 }
1066
1067 _handlePageUp(e: KeyboardEvent) {
1068 if (this._isSuggestionsFocused) {

Callers 1

_onkeydownMethod · 0.95

Calls 4

getInputDOMRefSyncMethod · 0.95
fireSelectionChangeMethod · 0.95
acceptSuggestionMethod · 0.95
onEnterMethod · 0.80

Tested by

no test coverage detected