[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) <anv@odoo.com>
This commit is contained in:
Antoine Vandevenne (anv) 2023-01-02 14:25:27 +00:00
parent 0ef10a1606
commit 9af7a4ca01

View File

@ -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.
}
});
};