[FIX] web: AutoComplete render only if options are available

There was a small graphical bug caused by the `<ul>` element being
rendered even when no options were available.

X-original-commit: 32d87b2097e550b375bdc2098cdee6c669666a3a
Part-of: odoo/odoo#102220
This commit is contained in:
Louis Baudoux
2022-10-06 00:36:57 +02:00
parent 5768b03bdc
commit 1ac1ad0fef
2 changed files with 10 additions and 1 deletions
@@ -49,6 +49,15 @@ export class AutoComplete extends Component {
return this.state.open;
}
get hasOptions() {
for (const source of this.sources) {
if (source.isLoading || source.options.length) {
return true;
}
}
return false;
}
open(useInput = false) {
this.state.open = true;
this.loadSources(useInput);
@@ -17,7 +17,7 @@
t-on-keydown="onInputKeydown"
t-ref="input"
/>
<t t-if="isOpened">
<t t-if="isOpened and hasOptions">
<ul class="o-autocomplete--dropdown-menu dropdown-menu ui-widget ui-autocomplete show" t-on-mousedown.prevent="" t-ref="sourcesList">
<t t-foreach="sources" t-as="source" t-key="source.id">
<t t-if="source.isLoading">