[FIX] web: Trim spaces when selecting option by text

It's quite common that the `$().text()` method returns lots of random whitespaces at the beginning and end of the string. They're pretty unpredictable (extension views can add or remove them) and invisible to the end user.

This code chunk should allow to select an `<option>` based on its raw text content, but most of them will just fail without this patch. And most chances are that current ones just work equally with this patch.

This will make frontend tours more pleasant to write.

closes odoo/odoo#32718

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Jairo Llopis
2019-04-16 11:53:47 +00:00
parent ecae2fc9ca
commit 94e35a19b3
@@ -87,7 +87,7 @@ var RunningTourActionHelper = core.Class.extend({
$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 = $options.filter(function () { return $(this).text().trim() === text; });
}
$selectedOption.prop("selected", true);
this._click(values);