Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui5-input): Suggestions can now be arbitrary list items #1969

Merged
merged 2 commits into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/main/src/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/features/InputSuggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down