[FIX] web: custom filter display on selection field
**Issue:** When creating a custom filter for a selection field, the selected value is not properly displayed. Note however that applying the filter still works. The problem is only in the displayed value. This is caused by setting the "value" attribute of the selection element which is always an empty string (because formatField doesn't properly work for selection field). However, the empty string is not the issue because it doesn't matter what "formatted value" is returned, it is not needed. The selection field's value is based on the value of the selected option. **Solution:** To properly show the display text of the selection item, we need to make sure that value of the selection field is not overridden during its onChange event. As a result, the selected option will become the value of the selection field, displaying the proper text. Therefore, in the onValueChange event handler, if the field type is selection, we don't reset the value of the the selection element. closes odoo/odoo#105420 X-original-commit: afadac5e21e6af2111ef42852243e78bb085d7c3 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
This commit is contained in:
@@ -313,7 +313,10 @@ export class CustomFilterItem extends Component {
|
||||
} catch (_err) {
|
||||
// Parsing error: nothing is done
|
||||
}
|
||||
ev.target.value = condition.displayedValue;
|
||||
// Only reset the target's value if it is not a selection field.
|
||||
if (field.type !== "selection") {
|
||||
ev.target.value = condition.displayedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -336,7 +336,7 @@ QUnit.module("Search", (hooks) => {
|
||||
});
|
||||
|
||||
QUnit.test("selection field: default and updated value", async function (assert) {
|
||||
assert.expect(10);
|
||||
assert.expect(11);
|
||||
|
||||
const controlPanel = await makeWithSearch({
|
||||
serverData,
|
||||
@@ -370,6 +370,11 @@ QUnit.module("Search", (hooks) => {
|
||||
await toggleAddCustomFilter(target);
|
||||
await editConditionField(target, 0, "color");
|
||||
await editConditionValue(target, 0, "white");
|
||||
assert.strictEqual(
|
||||
target.querySelector(".o_generator_menu_value input,.o_generator_menu_value select")
|
||||
.value,
|
||||
"white"
|
||||
);
|
||||
await applyFilter(target);
|
||||
|
||||
assert.deepEqual(getFacetTexts(target), ['Color is "white"']);
|
||||
|
||||
Reference in New Issue
Block a user