[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#32791 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -113,7 +113,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);
|
||||
|
||||
Reference in New Issue
Block a user