From 60c9eb9bdd97a17acb8676159d0467e15572dfc6 Mon Sep 17 00:00:00 2001 From: Wagner Trezub <60133113+Wagner3UB@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:01:50 +0200 Subject: [PATCH] fix: close Megamenu on mobile when click on subsite link (#635) * fix: closeMenu working when subsiteMenu diff from main * docs: rlease --- RELEASE.md | 1 + src/components/ItaliaTheme/MegaMenu/MegaMenu.jsx | 7 +++++-- .../volto/components/theme/Navigation/Navigation.jsx | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 11602e7ca..fc35800db 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -49,6 +49,7 @@ - Sistemato layout del menu laterale sinistro nella vista del Bando - Sistemato il flag Mostra tipologia bandi nel blocco elenco con variazione Bandi in Evidenza - Tradotto il messaggio per Screen Reader del bottone per aprire e chiudere il menu in mobile. +- Menu dropdown si chiude correttamente quando il percorso รจ un sottosito con un menu diverso rispetto al sito principale ## Versione 7.25.3 (07/03/2024) diff --git a/src/components/ItaliaTheme/MegaMenu/MegaMenu.jsx b/src/components/ItaliaTheme/MegaMenu/MegaMenu.jsx index f3250c935..ac31e8b4e 100644 --- a/src/components/ItaliaTheme/MegaMenu/MegaMenu.jsx +++ b/src/components/ItaliaTheme/MegaMenu/MegaMenu.jsx @@ -70,7 +70,7 @@ const isChildActive = (itemUrl, pathname) => { return pathname.indexOf(itemUrl) > -1; }; -const MegaMenu = ({ item, pathname }) => { +const MegaMenu = ({ item, pathname, closeMenu }) => { const intl = useIntl(); const blocksFieldname = getBlocksFieldname(item); const blocksLayoutFieldname = getBlocksLayoutFieldname(item); @@ -317,7 +317,10 @@ const MegaMenu = ({ item, pathname }) => { title={child.title} condition={!!child['@id']} key={child['@id']} - onClick={() => setMenuStatus(false)} + onClick={() => { + setMenuStatus(false); + closeMenu(); + }} className={cx('list-item', { active: isChildActive( flattenToAppURL(child['@id']), diff --git a/src/customizations/volto/components/theme/Navigation/Navigation.jsx b/src/customizations/volto/components/theme/Navigation/Navigation.jsx index 50370ae0a..229981508 100644 --- a/src/customizations/volto/components/theme/Navigation/Navigation.jsx +++ b/src/customizations/volto/components/theme/Navigation/Navigation.jsx @@ -140,6 +140,9 @@ const Navigation = ({ pathname }) => { item={item} pathname={pathname} key={index + 'mm'} + closeMenu={() => { + setCollapseOpen(false); + }} /> ))}