@@ -39,31 +39,42 @@ $(document).ready(function () {
3939 }
4040 }
4141
42- // Gestione click specifico sul testo del menu per navigare al modulo
43- $ ( document ) . on ( 'click' , '.nav-sidebar .menu-text' , function ( e ) {
42+ // Gestione click sull'intero link del menu per navigare al modulo
43+ $ ( document ) . on ( 'click' , '.nav-sidebar .nav-link[data-has-submenu="true"]' , function ( e ) {
44+ // Se il click è sulla freccia, non fare nulla (lascia che gestisca il toggle)
45+ if ( $ ( e . target ) . hasClass ( 'fa-angle-left' ) ) {
46+ return ;
47+ }
48+
4449 e . preventDefault ( ) ;
4550 e . stopPropagation ( ) ;
4651
47- const $link = $ ( this ) . closest ( '.nav-link[data-has-submenu="true"]' ) ;
48- const href = $link . attr ( 'href' ) ;
52+ const href = $ ( this ) . attr ( 'href' ) ;
4953
5054 if ( href && href !== 'javascript:;' && href !== '#' ) {
5155 window . location . href = href ;
5256 }
5357 } ) ;
5458
55- // Gestione click sull'icona freccia per compattare quando il menu è espanso
56- $ ( document ) . on ( 'click' , '.nav-sidebar .nav-item.menu-open > .nav- link[data-widget="treeview"] .fa-angle-left' , function ( e ) {
59+ // Gestione click sull'icona freccia per toggle del menu
60+ $ ( document ) . on ( 'click' , '.nav-sidebar .nav-link[data-widget="treeview"] .fa-angle-left' , function ( e ) {
5761 e . preventDefault ( ) ;
5862 e . stopPropagation ( ) ;
5963
6064 const $navItem = $ ( this ) . closest ( '.nav-item' ) ;
65+ const $navLink = $ ( this ) . closest ( '.nav-link' ) ;
6166
62- // Compatta il menu solo se è attualmente espanso
67+ // Toggle del menu
6368 if ( $navItem . hasClass ( 'menu-open' ) ) {
69+ // Compatta il menu
6470 $navItem . removeClass ( 'menu-open' ) ;
65- $ ( this ) . closest ( '.nav-link' ) . attr ( 'aria-expanded' , 'false' ) ;
71+ $navLink . attr ( 'aria-expanded' , 'false' ) ;
6672 $navItem . find ( '.nav-treeview' ) . slideUp ( 300 ) ;
73+ } else {
74+ // Espande il menu
75+ $navItem . addClass ( 'menu-open' ) ;
76+ $navLink . attr ( 'aria-expanded' , 'true' ) ;
77+ $navItem . find ( '.nav-treeview' ) . slideDown ( 300 ) ;
6778 }
6879 } ) ;
6980
0 commit comments