@@ -121,17 +121,18 @@ class Menu extends Element {
121121 if ( this . _render_task ) await new Promise ( ( resolve ) => {
122122 this . route_handler_lock = resolve
123123 } )
124- var page = event . current_route
125- if ( page . length == 1 ) {
124+ if ( event . current_route . length < 2 ) {
126125 ( ( ) => {
127- const first_menu = Object . values ( this . $menus ) [ 0 ]
128- if ( first_menu . children . length != 0 ) {
129- first_menu . children [ 0 ] . $dom . click ( ) ;
126+ const [ menu , value ] = Object . entries ( this . $menus ) [ 0 ]
127+ if ( value . children . length != 0 ) {
128+ value . children [ 0 ] . $dom . click ( ) ;
130129 } else {
131- first_menu . $dom . click ( ) ;
130+ $router . page ( "/" + menu )
132131 }
133132 } ) ( ) ;
133+ return ;
134134 }
135+ var page = event . current_route
135136 var [ key , sub ] = page . slice ( 1 ) . split ( "/" , 2 )
136137 if ( cur_key == key && cur_sub == sub ) return ;
137138 for ( const [ $key , $val ] of Object . entries ( this . $menus ) ) {
@@ -375,6 +376,7 @@ class SwitchElement extends Element {
375376 this . index = null ;
376377 this . _render_next_index = null ;
377378 this . observer = new ResizeObserver ( ( ) => {
379+ if ( this . index == null ) return ;
378380 this . select ( this . index )
379381 } )
380382 this . observer . observe ( this . origin )
@@ -404,14 +406,15 @@ class SwitchElement extends Element {
404406 }
405407 this . $main . append ( ...this . $buttons )
406408 if ( this . _render_next_index != null ) {
409+ const next_index = this . _render_next_index ;
410+ this . _render_next_index = null ;
407411 requestAnimationFrame ( ( ) => {
408- this . select ( this . _render_next_index ) ;
409- this . _render_next_index = null ;
412+ this . select ( next_index ) ;
410413 } )
411414 }
412415 }
413416 select ( index ) {
414- if ( this . _render_task ) {
417+ if ( this . _render_task || this . $buttons . length == 0 ) {
415418 this . _render_next_index = index ;
416419 return this ;
417420 } ;
@@ -957,6 +960,7 @@ async function load() {
957960 const $menu = new Menu ( )
958961 const $menu_variables = { } ;
959962 $menu . add ( "dashboard" , "a" , ( ...args ) => {
963+ console . log ( "triggered" )
960964 if ( ! $menu_variables . dashboard ) {
961965 $menu_variables . dashboard = { } ;
962966 }
@@ -1668,7 +1672,7 @@ async function load() {
16681672 while ( $main . firstChild != null ) {
16691673 $main . removeChild ( $main . firstChild )
16701674 }
1671- clearDashboardTask ( true )
1675+ // clearDashboardTask(true)
16721676 } )
16731677
16741678 for ( const $theme_key in $theme ) {
0 commit comments