(item: IInputSuggestionItemSelectable, keyboardUsed: boolean)
| 1538 | } |
| 1539 | |
| 1540 | acceptSuggestion(item: IInputSuggestionItemSelectable, keyboardUsed: boolean) { |
| 1541 | if (this._isGroupItem(item)) { |
| 1542 | return; |
| 1543 | } |
| 1544 | |
| 1545 | let originalItem = item; |
| 1546 | if (this._matchedSuggestionItem) { |
| 1547 | const matchedText = this._matchedSuggestionItem.text?.toLowerCase() || ""; |
| 1548 | const itemText = item.text?.toLowerCase() || ""; |
| 1549 | // Only use matched item if keyboard navigation or if it's the same item (case-insensitive) |
| 1550 | if (keyboardUsed || matchedText === itemText) { |
| 1551 | originalItem = this._matchedSuggestionItem; |
| 1552 | } |
| 1553 | } |
| 1554 | |
| 1555 | const itemText = originalItem.text || ""; |
| 1556 | const fireChange = keyboardUsed |
| 1557 | ? this.valueBeforeItemSelection !== itemText : this.previousValue !== itemText; |
| 1558 | |
| 1559 | this.hasSuggestionItemSelected = true; |
| 1560 | this.value = itemText; |
| 1561 | |
| 1562 | if (fireChange && (this.previousValue !== itemText)) { |
| 1563 | this.valueBeforeItemSelection = itemText; |
| 1564 | this.lastConfirmedValue = itemText; |
| 1565 | |
| 1566 | this._performTextSelection = true; |
| 1567 | |
| 1568 | this.fireDecoratorEvent(INPUT_EVENTS.CHANGE); |
| 1569 | |
| 1570 | this._isChangeTriggeredBySuggestion = true; |
| 1571 | // value might change in the change event handler |
| 1572 | this.typedInValue = this.value; |
| 1573 | this.previousValue = this.value; |
| 1574 | } |
| 1575 | |
| 1576 | this.valueBeforeSelectionStart = ""; |
| 1577 | this._matchedSuggestionItem = undefined; |
| 1578 | |
| 1579 | this.isTyping = false; |
| 1580 | this.open = false; |
| 1581 | } |
| 1582 | |
| 1583 | /** |
| 1584 | * Updates the input value on item select. |
no test coverage detected