From 9af7a4ca0133f438e8878b98c63bcf8c2198158a Mon Sep 17 00:00:00 2001 From: "Antoine Vandevenne (anv)" Date: Mon, 2 Jan 2023 14:25:27 +0000 Subject: [PATCH] [FIX] odoo_theme: handle non-TOC pages when expanding top menu entries Trying to "expand" those pages lead to a crash that prevented the menu to be shown at all. Incidentally, this commit also handles menus built with `make fast`. closes odoo/documentation#3275 Signed-off-by: Antoine Vandevenne (anv) --- extensions/odoo_theme/static/js/menu.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/extensions/odoo_theme/static/js/menu.js b/extensions/odoo_theme/static/js/menu.js index 9276acfb5..8862e9202 100644 --- a/extensions/odoo_theme/static/js/menu.js +++ b/extensions/odoo_theme/static/js/menu.js @@ -78,8 +78,11 @@ * @param {HTMLElement} navigationMenu - The navigation menu. */ const _expandTopMenus = navigationMenu => { - navigationMenu.querySelectorAll('.toctree-l1').forEach(element => { - element.querySelector('ul').classList.add('show'); // Expand the top-level menus. + navigationMenu.querySelectorAll('.toctree-l1').forEach(tocEntry => { + const childTocEntryList = tocEntry.querySelector('ul'); + if (childTocEntryList) { // The TOC entry has an associated TOC entry list. + childTocEntryList.classList.add('show'); // Expand the top-level menus. + } }); };