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

Method _handleEscape

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

Source from the content-addressed store, hash-verified

1093 }
1094
1095 _handleEscape() {
1096 const hasSuggestions = this.showSuggestions && !!this.Suggestions;
1097 const isOpen = hasSuggestions && this.open;
1098 const innerInput = this.getInputDOMRefSync()!;
1099 const isAutoCompleted = innerInput.selectionEnd! - innerInput.selectionStart! > 0;
1100
1101 this.isTyping = false;
1102 this._matchedSuggestionItem = undefined;
1103
1104 if (this.value !== this.previousValue && this.value !== this.lastConfirmedValue && !this.open) {
1105 this.value = this.lastConfirmedValue ? this.lastConfirmedValue : this.previousValue;
1106 this.fireDecoratorEvent(INPUT_EVENTS.INPUT, { inputType: "" });
1107
1108 return;
1109 }
1110
1111 if (!isOpen) {
1112 this.value = this.lastConfirmedValue ? this.lastConfirmedValue : this.previousValue;
1113 return;
1114 }
1115
1116 if (isOpen && this.Suggestions?._isItemOnTarget()) {
1117 // Restore the value.
1118 this.value = this.typedInValue || this.valueBeforeSelectionStart;
1119
1120 this.focused = true;
1121
1122 return;
1123 }
1124
1125 if (isAutoCompleted) {
1126 this.value = this.typedInValue;
1127 }
1128
1129 this.focused = true;
1130 }
1131
1132 _onfocusin(e: FocusEvent) {
1133 this.focused = true; // invalidating property

Callers 1

_onkeydownMethod · 0.95

Calls 2

getInputDOMRefSyncMethod · 0.95
_isItemOnTargetMethod · 0.80

Tested by

no test coverage detected