Skip to content
Snippets Groups Projects
Commit 164db401 authored by can-odoo's avatar can-odoo Committed by Guillaume (gdi)
Browse files

[FIX] website: remove ToC snippet on removing last content


The user has the option to remove the last block from the Table of
Content snippet prior to this commit, but doing so breaks the Add Item
feature because there is no reference to adding a new item in the
snippet area, and doing so is also not a good idea.

If the block is the final one in the Table of Content after this commit,
removing the last Content will remove the ToC snippet.

task-3081442

closes odoo/odoo#130584

X-original-commit: d3313ba8
Signed-off-by: default avatarGuillaume Dieleman (gdi) <gdi@odoo.com>
parent 182a98d5
Branches
Tags
No related merge requests found
......@@ -78,6 +78,16 @@ options.registry.TableOfContent = options.Class.extend({
* @private
*/
_generateNav: function (ev) {
const blockTextContent = this.$target[0].textContent.replaceAll('\n', '').trim();
if (blockTextContent === '') {
// destroy public widget and remove the ToC since there are no more
// child elements, before doing so the observer needs to be
// disconnected else observer observe mutation and _generateNav
// gets called even after there's no more ToC.
this.observer.disconnect();
this.trigger_up('remove_snippet', {$snippet: this.$target});
return;
}
this.options.wysiwyg && this.options.wysiwyg.odooEditor.unbreakableStepUnactive();
const headingsEls = this.$target.find(this.targetedElements).toArray()
.filter(el => !el.closest('.o_snippet_desktop_invisible'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment