From 17a9e455669397c6be84ecc28a86f4196576badc Mon Sep 17 00:00:00 2001 From: Adrien Dieudonne Date: Wed, 26 Jul 2017 11:17:08 +0200 Subject: [PATCH] [FIX] web_tour: tour_manager: choose option for select element Before this commit, it was only possible to set an option with his value. For example: The only way to set the first option was to do the following: run: "text 1" With this commit, we can now select the first option with his text value: run "test One" We need this because in 'main_flow_tour', some values are generated ids. --- addons/web_tour/static/src/js/tour_manager.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/web_tour/static/src/js/tour_manager.js b/addons/web_tour/static/src/js/tour_manager.js index 829c06e7dc5..8d6d35c102f 100644 --- a/addons/web_tour/static/src/js/tour_manager.js +++ b/addons/web_tour/static/src/js/tour_manager.js @@ -146,10 +146,13 @@ var RunningTourActionHelper = core.Class.extend({ if (values.consume_event === "input") { values.$element.trigger("keydown").val(text).trigger("keyup").trigger("input"); } else if (values.$element.is("select")) { - values.$element.children("option") - .prop("selected", false).removeProp("selected") - .filter(function () { return $(this).val() === text; }) - .prop("selected", true); + var $options = values.$element.children("option"); + $options.prop("selected", false).removeProp("selected"); + var $selectedOption = $options.filter(function () { return $(this).val() === text; }); + if ($selectedOption.length === 0) { + $selectedOption = $options.filter(function () { return $(this).text() === text; }); + } + $selectedOption.prop("selected", true); this._click(values); } else { values.$element.text(text);