From 70a80d4cd12e7a4970c474fc791d17adbc5116ff Mon Sep 17 00:00:00 2001 From: FrancoisGe Date: Tue, 18 Oct 2022 06:51:08 +0000 Subject: [PATCH] [FIX] web: click on wrong options in autocomplete MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The purpose of this commit is to fix an indeterminate error in the test_03_sale_quote_tour. Error: UncaughtTypeError: Cannot read properties of undefined (reading 'unselectable') Why: In the autocomplete component, it is possible to replace the sources without it being rerender. It is therefore possible to click on a option that no longer exists in the component's internal state, which causes the crash. Solution: We wait that all the sources are loaded before replacing them. closes odoo/odoo#103497 X-original-commit: f25df0be75082caf9e8ed62c581a13fe82a27546 Signed-off-by: Samuel Degueldre Signed-off-by: Georis François (fge) --- .../static/src/js/tours/mass_mailing_editor_tour.js | 2 -- addons/web/static/src/core/autocomplete/autocomplete.js | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/mass_mailing/static/src/js/tours/mass_mailing_editor_tour.js b/addons/mass_mailing/static/src/js/tours/mass_mailing_editor_tour.js index e0c1651f84b..402e9d92e27 100644 --- a/addons/mass_mailing/static/src/js/tours/mass_mailing_editor_tour.js +++ b/addons/mass_mailing/static/src/js/tours/mass_mailing_editor_tour.js @@ -12,8 +12,6 @@ odoo.define('mass_mailing.mass_mailing_editor_tour', function (require) { trigger: 'button.o_list_button_add', }, { trigger: 'div[name="contact_list_ids"] .o_input_dropdown input[type="text"]', - }, { - trigger: 'li.ui-menu-item', }, { trigger: 'div[name="contact_list_ids"] .ui-state-active' }, { diff --git a/addons/web/static/src/core/autocomplete/autocomplete.js b/addons/web/static/src/core/autocomplete/autocomplete.js index 23cb0e8dc9e..c7b39ad02c9 100644 --- a/addons/web/static/src/core/autocomplete/autocomplete.js +++ b/addons/web/static/src/core/autocomplete/autocomplete.js @@ -91,8 +91,9 @@ export class AutoComplete extends Component { source.options = options.map((option) => this.makeOption(option)); } } - this.sources = sources; + Promise.all(proms).then(() => { + this.sources = sources; this.navigate(0); }); }