[FIX] web: m2oautocomplete in some weird cases
Part-of: odoo/odoo#95804
This commit is contained in:
committed by
Géry Debongnie
parent
6107e07971
commit
bebc565269
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
/>
|
||||
<AutoComplete t-else=""
|
||||
value="state.autocompleteValue"
|
||||
value="props.value"
|
||||
id="props.id"
|
||||
placeholder="props.placeholder"
|
||||
sources="sources"
|
||||
@@ -50,7 +50,6 @@
|
||||
onSelect.bind="onSelect"
|
||||
onInput.bind="onInput"
|
||||
onChange.bind="onChange"
|
||||
forceClose="forceClose"
|
||||
/>
|
||||
<a role="button" class="o_dropdown_button" draggable="false" />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user