()
| 1446 | } |
| 1447 | |
| 1448 | _handleEnter() { |
| 1449 | const lowerCaseValue = this.value.toLowerCase(); |
| 1450 | const matchingItem = this._getItems().find(item => (!item.isGroupItem && item.text!.toLowerCase() === lowerCaseValue)); |
| 1451 | const oldValueState = this.valueState; |
| 1452 | const innerInput = this._innerInput; |
| 1453 | |
| 1454 | if (matchingItem) { |
| 1455 | if (matchingItem.selected) { |
| 1456 | if (this._validationTimeout) { |
| 1457 | return; |
| 1458 | } |
| 1459 | this._updateValueState(ValueState.Negative); |
| 1460 | this._performingSelectionTwice = true; |
| 1461 | this._resetValueState(oldValueState, () => { |
| 1462 | this._performingSelectionTwice = false; |
| 1463 | }); |
| 1464 | } else { |
| 1465 | this._previouslySelectedItems = this._getSelectedItems(); |
| 1466 | const previousSelectedValues = [...this.selectedValues]; |
| 1467 | matchingItem.selected = true; |
| 1468 | this.value = ""; |
| 1469 | // during composition prevent _inputLiveChange for proper input clearing |
| 1470 | if (this._isComposing) { |
| 1471 | this._suppressNextLiveChange = true; |
| 1472 | } |
| 1473 | |
| 1474 | if (this.selectedValues && matchingItem.value) { |
| 1475 | this.selectedValues = [...this.selectedValues, matchingItem.value]; |
| 1476 | } |
| 1477 | |
| 1478 | const changePrevented = this.fireSelectionChange(); |
| 1479 | |
| 1480 | if (changePrevented) { |
| 1481 | this.selectedValues = previousSelectedValues; |
| 1482 | this._revertSelection(); |
| 1483 | } |
| 1484 | } |
| 1485 | |
| 1486 | innerInput.setSelectionRange(matchingItem.text!.length, matchingItem.text!.length); |
| 1487 | this.open = false; |
| 1488 | } else { |
| 1489 | // If dropdown is open with a focused item, just close it instead of submitting |
| 1490 | if (this.open && this._getList()._itemNavigation._currentIndex >= 0) { |
| 1491 | this.open = false; |
| 1492 | return; |
| 1493 | } |
| 1494 | |
| 1495 | if (this._lastValue !== this.value) { |
| 1496 | this._inputChange(); |
| 1497 | } |
| 1498 | |
| 1499 | if (this._internals?.form) { |
| 1500 | submitForm(this); |
| 1501 | } |
| 1502 | } |
| 1503 | } |
| 1504 | |
| 1505 | _resetValueState(valueState: `${ValueState}`, callback?: () => void) { |
nothing calls this directly
no test coverage detected