From aa6fde4116cadbc5b380112342ba38d07063a927 Mon Sep 17 00:00:00 2001 From: Vladislav Tasev Date: Thu, 23 Jul 2020 10:55:19 +0300 Subject: [PATCH] fix(ui5-input): Suggestions can now be arbitrary list items (#1969) --- packages/main/src/Input.js | 9 +++++---- packages/main/src/features/InputSuggestions.js | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/main/src/Input.js b/packages/main/src/Input.js index 631fc1ca74e3..fb080c506e76 100644 --- a/packages/main/src/Input.js +++ b/packages/main/src/Input.js @@ -799,18 +799,19 @@ class Input extends UI5Element { } previewSuggestion(item) { - const emptyValue = item.type === "Inactive" || item.group; this.valueBeforeItemSelection = this.value; - this.updateValueOnPreview(emptyValue ? "" : item.effectiveTitle); + this.updateValueOnPreview(item); this.announceSelectedItem(); this._previewItem = item; } /** * Updates the input value on item preview. - * @param {itemValue} itemValue The value of the item that is on preview + * @param {Object} item The item that is on preview */ - updateValueOnPreview(itemValue) { + updateValueOnPreview(item) { + const noPreview = item.type === "Inactive" || item.group; + const itemValue = noPreview ? "" : (item.effectiveTitle || item.textContent); this.value = itemValue; } diff --git a/packages/main/src/features/InputSuggestions.js b/packages/main/src/features/InputSuggestions.js index 85da40dc846e..dec676bf2fb9 100644 --- a/packages/main/src/features/InputSuggestions.js +++ b/packages/main/src/features/InputSuggestions.js @@ -318,7 +318,7 @@ class Suggestions { } _getItems() { - return [].slice.call(this.responsivePopover.querySelectorAll("ui5-li-groupheader, ui5-li-suggestion-item")); + return [...this.responsivePopover.querySelectorAll("ui5-list>*")]; } _getComponent() {