From 89a9253ccf4247ade2f774596755d742aeba8643 Mon Sep 17 00:00:00 2001 From: std-odoo Date: Fri, 9 Sep 2022 07:14:45 +0000 Subject: [PATCH] [IMP] web: always reset the autocomplete input for properties tags Purpose ======= Always reset the autocomplete value when creating a new tag, even if the tag already exists. Technical ========= The input value is reset when the tag is created because the props of the autocomplete component change, but if we do not change the props of the autocomplete component (e.g. because the tag already exist and nothing should be done), the text value is not reset. Add a new option for that purpose. Task-2965523 X-original-commit: 352e811e821ef7c1fc075c32dda7272145749526 Part-of: odoo/odoo#101487 --- addons/web/static/src/core/autocomplete/autocomplete.js | 5 +++++ .../web/static/src/views/fields/properties/property_tags.xml | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/core/autocomplete/autocomplete.js b/addons/web/static/src/core/autocomplete/autocomplete.js index 7b29cf4779a..897c439ba7b 100644 --- a/addons/web/static/src/core/autocomplete/autocomplete.js +++ b/addons/web/static/src/core/autocomplete/autocomplete.js @@ -124,6 +124,10 @@ export class AutoComplete extends Component { return; } + if (this.props.resetOnSelect) { + this.inputRef.el.value = ""; + } + this.forceValFromProp = true; this.props.onSelect(option, { ...params, @@ -295,6 +299,7 @@ Object.assign(AutoComplete, { }, placeholder: { type: String, optional: true }, autoSelect: { type: Boolean, optional: true }, + resetOnSelect: { type: Boolean, optional: true }, onInput: { type: Function, optional: true }, onChange: { type: Function, optional: true }, onBlur: { type: Function, optional: true }, diff --git a/addons/web/static/src/views/fields/properties/property_tags.xml b/addons/web/static/src/views/fields/properties/property_tags.xml index a4e7e12c0f3..828bf556eb8 100644 --- a/addons/web/static/src/views/fields/properties/property_tags.xml +++ b/addons/web/static/src/views/fields/properties/property_tags.xml @@ -12,7 +12,8 @@ + onSelect.bind="({value}) => this.onOptionSelected(value)" + resetOnSelect="true"/>