diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index 761fae6f816..3b75e99d367 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -1492,6 +1492,13 @@ options.registry.anchorName = options.Class.extend({ click: function () { var $input = this.$('.o_input_anchor_name'); var anchorName = $input.val().trim().replace(/\s/g, '_'); + if (self.$target[0].id === anchorName) { + // If the chosen anchor name is already the one used by the + // element, close the dialog and do nothing else + this.close(); + return; + } + var isValid = /^[\w-]+$/.test(anchorName); var alreadyExists = isValid && $('#' + anchorName).length > 0; var anchorOK = isValid && !alreadyExists; diff --git a/addons/website/views/snippets.xml b/addons/website/views/snippets.xml index 1e4e72dd4f7..5beb1bc2980 100644 --- a/addons/website/views/snippets.xml +++ b/addons/website/views/snippets.xml @@ -1444,7 +1444,7 @@