diff --git a/addons/web/static/src/core/autocomplete/autocomplete.js b/addons/web/static/src/core/autocomplete/autocomplete.js index d90b99c5eec..baff6bd6b4d 100644 --- a/addons/web/static/src/core/autocomplete/autocomplete.js +++ b/addons/web/static/src/core/autocomplete/autocomplete.js @@ -29,7 +29,8 @@ export class AutoComplete extends Component { this.hotkeysToRemove = []; owl.onWillUpdateProps((nextProps) => { - if (nextProps.forceClose) { + if (this.props.value !== nextProps.value || this.forceValFromProp) { + this.forceValFromProp = false; this.inputRef.el.value = nextProps.value; this.close(); } @@ -124,6 +125,7 @@ export class AutoComplete extends Component { } selectOption(indices, params = {}) { this.inputRef.el.value = ""; + this.forceValFromProp = true; const option = this.sources[indices[0]].options[indices[1]]; if (option.unselectable) { @@ -304,7 +306,6 @@ Object.assign(AutoComplete, { onInput: { type: Function, optional: true }, onChange: { type: Function, optional: true }, onBlur: { type: Function, optional: true }, - forceClose: { type: Boolean, optional: true }, }, defaultProps: { placeholder: "", @@ -312,7 +313,6 @@ Object.assign(AutoComplete, { onInput: () => {}, onChange: () => {}, onBlur: () => {}, - forceClose: false, }, timeout: 250, }); diff --git a/addons/web/static/src/views/fields/relational_utils.js b/addons/web/static/src/views/fields/relational_utils.js index 0ef40218dca..96bbd083b6a 100644 --- a/addons/web/static/src/views/fields/relational_utils.js +++ b/addons/web/static/src/views/fields/relational_utils.js @@ -156,11 +156,6 @@ export class Many2XAutocomplete extends owl.Component { this.orm = useService("orm"); const autoCompleteContainer = useForwardRefToParent("autocomplete_container"); - - this.state = owl.useState({ - autocompleteValue: this.props.value, - }); - const { activeActions, resModel, update, isToMany, fieldString } = this.props; this.openMany2X = useOpenMany2XRecord({ @@ -186,19 +181,6 @@ export class Many2XAutocomplete extends owl.Component { }, onCreateEdit: ({ context }) => this.openMany2X({ context }), }); - - this.forceClose = false; - owl.onWillUpdateProps((nextProps) => { - this.state.autocompleteValue = nextProps.value; - if (this.preventClose) { - return; - } - this.forceClose = true; - }); - owl.useEffect(() => { - this.forceClose = false; - this.preventClose = false; - }); } get sources() { @@ -223,7 +205,6 @@ export class Many2XAutocomplete extends owl.Component { } onInput({ inputValue }) { if (!this.props.value || this.props.value !== inputValue) { - this.preventClose = true; this.props.setInputFloats(true); } } @@ -232,7 +213,6 @@ export class Many2XAutocomplete extends owl.Component { if (option.action) { return option.action(params); } - this.state.autocompleteValue = ""; const record = { id: option.value, name: option.label, diff --git a/addons/web/static/src/views/fields/relational_utils.xml b/addons/web/static/src/views/fields/relational_utils.xml index febb3696219..f0da470686d 100644 --- a/addons/web/static/src/views/fields/relational_utils.xml +++ b/addons/web/static/src/views/fields/relational_utils.xml @@ -38,11 +38,11 @@ t-att-id="props.id" class="o_input" readonly="" - t-att-value="state.autocompleteValue" + t-att-value="props.value" t-on-click="onSearchMore" />