[FIX] website: re-render the visibility selector on field label change

Steps to reproduce the bug:
- Add a form on the website.
- Add two fields on the form ("A" and "B").
- Change the conditional visibility of "B" and put it to "Visible only
if".
- Change the label of "B" and set it to "A".
- Try to change the dependent field.

-> "A" is still on the list of the eligible dependent fields. It should
not be the case as setting this field as a dependent field would create
a circular dependency.

To solve the problem, the file visibility selector is rerendered after
modifying a field label. Because of the `_findCircular()` check at the
rerendering, the problematic field will not be displayed in the list of
of the eligible dependent fields.

task-3291044

closes odoo/odoo#140928

X-original-commit: 788218dff61e65f2213c31ebc660183ef3e73087
Signed-off-by: Arthur Detroux (ard) <ard@odoo.com>
Signed-off-by: Colin Louis (loco) <loco@odoo.com>
This commit is contained in:
Louis (loco)
2023-11-06 11:16:42 +00:00
parent 92e3cf48b2
commit f13a8afdbc
2 changed files with 20 additions and 0 deletions
@@ -1031,6 +1031,13 @@ options.registry.WebsiteFieldEditor = FieldEditor.extend({
dependentEl.dataset.visibilityDependency = value;
}
}
if (!previewMode) {
// As the field label changed, the list of available visibility
// dependencies needs to be updated in order to not propose a
// field that would create a circular dependency.
this.rerender = true;
}
}
},
/**
@@ -208,6 +208,19 @@
trigger: "we-customizeblock-option.snippet-option-WebsiteFieldEditor we-select:contains('Visibility'):has(we-toggler:contains('Always Visible'))",
run: () => null,
},
...addCustomField("char", "text", "Conditional Visibility Check 5", false),
...addCustomField("char", "text", "Conditional Visibility Check 6", false),
...selectButtonByData("data-set-visibility='conditional'"),
{
content: "Change the label of 'Conditional Visibility Check 6' and change it to 'Conditional Visibility Check 5'",
trigger: 'we-input[data-set-label-text] input',
run: "text Conditional Visibility Check 5",
},
{
content: "Check that 'Conditional Visibility Check 5' is not in the list of the renamed field",
trigger: "we-customizeblock-option.snippet-option-WebsiteFieldEditor we-select[data-name='hidden_condition_opt']:not(:has(we-button:contains('Conditional Visibility Check 5')))",
run: () => null,
},
...addExistingField('email_cc', 'text', 'Test conditional visibility', false, {visibility: CONDITIONALVISIBILITY, condition: 'odoo'}),
...addExistingField('date', 'text', 'Test Date', true),