diff --git a/addons/website/static/src/snippets/s_website_form/options.js b/addons/website/static/src/snippets/s_website_form/options.js index 0540df3126e..d772f29a13c 100644 --- a/addons/website/static/src/snippets/s_website_form/options.js +++ b/addons/website/static/src/snippets/s_website_form/options.js @@ -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; + } } }, /** diff --git a/addons/website/static/tests/tours/website_form_editor.js b/addons/website/static/tests/tours/website_form_editor.js index adf9de52a4b..d4ed78e1280 100644 --- a/addons/website/static/tests/tours/website_form_editor.js +++ b/addons/website/static/tests/tours/website_form_editor.js @@ -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),