Skip to content

Commit 65af83d

Browse files
[FIX] web_widget_product_label_section_and_note: Use a flag to change the icon based on product visibility.
Before this commit, when isProductVisible was disabled and the user changed the label, this caused isProductVisible to change its value. After this commit, changing the label no longer modifies isProductVisible.
1 parent bc4f109 commit 65af83d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

web_widget_product_label_section_and_note/static/src/components/product_label_section_and_note_field/product_label_section_and_note_field.esm.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export class ProductLabelSectionAndNoteField extends Many2OneField {
154154
this.labelVisibility = useState({value: false});
155155
this.isProductVisible = useState({value: false});
156156
this.switchToLabel = false;
157+
this.changeProductVisibility = true;
157158
this.columnIsProductAndLabel = useState({
158159
value: this.props.record.columnIsProductAndLabel,
159160
});
@@ -203,8 +204,10 @@ export class ProductLabelSectionAndNoteField extends Many2OneField {
203204
window.removeEventListener("afterprint", this.onAfterPrint);
204205
});
205206
useRecordObserver(async (record) => {
206-
const label = record.data.name || "";
207-
this.isProductVisible.value = label.includes(this.productName);
207+
if (this.changeProductVisibility) {
208+
const label = record.data.name || "";
209+
this.isProductVisible.value = label.includes(this.productName);
210+
}
208211
});
209212
}
210213

@@ -276,9 +279,12 @@ export class ProductLabelSectionAndNoteField extends Many2OneField {
276279
}
277280

278281
updateLabel(value) {
282+
this.changeProductVisibility = false;
279283
this.props.record.update({
280284
name:
281-
this.productName && this.productName !== value
285+
this.productName &&
286+
this.productName !== value &&
287+
this.isProductVisible.value
282288
? `${this.productName}\n${value}`
283289
: value,
284290
});

0 commit comments

Comments
 (0)