From 0ef10a16065ca4aaeed194858806a43d9d91ad2a Mon Sep 17 00:00:00 2001 From: "Antoine Vandevenne (anv)" Date: Mon, 2 Jan 2023 14:18:24 +0000 Subject: [PATCH] [IMP] odoo_theme: scroll the active menu entry into view In large and deeply nested TOCs like finance/accounting/fiscal_localizations/localizations/... the user had to constantly scroll the menu to the menu entry they just clicked because the expanded menu would not fit entirely on the page. With this commit, the active menu entry is scrolled into view each time the page is reloaded. The previous behavior was also the reason for expanding the top menu entries on only the homepage. Thanks to the scroll, they now always expand. Part-of: odoo/documentation#3275 --- extensions/odoo_theme/static/js/menu.js | 54 +++++++++++++++++-------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/extensions/odoo_theme/static/js/menu.js b/extensions/odoo_theme/static/js/menu.js index fa6af0b59..9276acfb5 100644 --- a/extensions/odoo_theme/static/js/menu.js +++ b/extensions/odoo_theme/static/js/menu.js @@ -9,13 +9,16 @@ // Allow to respectively highlight and expand the TOC entries and their related TOC entry // list whose page is displayed. - _flagActiveTocEntriesAndLists(navigationMenu); + const deepestActiveTocEntries = _flagActiveTocEntriesAndLists(navigationMenu); - // Expand the top-level menu items on the homepage. + // Expand the top-level menu items. _expandTopMenus(navigationMenu); // Show hidden menu when the css classes have been properly specified navigationMenu.removeAttribute('hidden'); + + // Scroll the menu to the deepest active TOC entry. + _scrollToDeepestActiveTocEntry(deepestActiveTocEntries); }); /** @@ -23,17 +26,18 @@ * * TOC entries (
  • elements) that are on the path of the displayed page receive the * `o_active_toc_entry` class, and their related (parent) TOC entry list (