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 expandable search bar issue w/ the dropdown options (quick search) #553

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
1 change: 0 additions & 1 deletion packages/expandable-search-bar/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ <h1>Expandable</h1>

function quickSearchSelected(e) {
console.log('quickSearchSelected', e.detail.quickSearchEntry);
document.getElementById('expanding-search-bar').searchTerm = e.detail.quickSearchEntry.displayText;
}
</script>
</body>
Expand Down
14 changes: 13 additions & 1 deletion packages/expandable-search-bar/src/expandable-search-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
property,
CSSResult,
TemplateResult,
PropertyValues,
} from 'lit-element';

import magnifyingGlassIcon from './assets/img/magnifying-glass';
Expand Down Expand Up @@ -80,6 +81,17 @@ export default class ExpandableSearchBar extends LitElement {
`;
}

/**
* Update the DOM element after the value of `this.searchTerm` changes
*
* @memberof ExpandableSearchBar
*/
updated(props: PropertyValues): void {
if (props.has('searchTerm') && this.searchInput) {
this.searchInput.value = this.searchTerm;
}
}

/**
* Called when then user clicks the X button to clear the search
*
Expand All @@ -90,7 +102,6 @@ export default class ExpandableSearchBar extends LitElement {
this.searchTerm = '';
/* istanbul ignore else */
if (this.searchInput) {
this.searchInput.value = '';
this.searchInput.focus();
jbuckner marked this conversation as resolved.
Show resolved Hide resolved
}
this.emitSearchClearedEvent();
Expand Down Expand Up @@ -165,6 +176,7 @@ export default class ExpandableSearchBar extends LitElement {
* @memberof ExpandableSearchBar
*/
private quickSearchSelected(e: CustomEvent): void {
this.searchTerm = e.detail.searchEntry.displayText;
const event = new CustomEvent('quickSearchSelected', {
detail: { quickSearchEntry: e.detail.searchEntry },
});
Expand Down