File tree Expand file tree Collapse file tree 3 files changed +15
-17
lines changed
Expand file tree Collapse file tree 3 files changed +15
-17
lines changed Original file line number Diff line number Diff line change @@ -413,24 +413,13 @@ test.describe('Keyboard UI Toggles', () => {
413413 await expect ( waitingOverlay ) . toHaveClass ( / a c t i v e / ) ;
414414 } ) ;
415415
416- test ( 't toggles table of contents (hidden in git mode, but toggles)' , async ( { page } ) => {
417- // In git mode, the tocToggle button is hidden (display: none), so pressing t clicks a hidden button.
418- // The toc starts with toc-hidden. Pressing t clicks the toggle button.
419- // Since the button is display:none in git mode, the click via keyboard shortcut
420- // still fires the click handler. Let's verify toc state changes.
416+ test ( 't does nothing in git mode (TOC is disabled)' , async ( { page } ) => {
421417 const toc = page . locator ( '#toc' ) ;
422418
423419 // Initially has toc-hidden
424420 await expect ( toc ) . toHaveClass ( / t o c - h i d d e n / ) ;
425421
426- // Press t
427- await page . keyboard . press ( 't' ) ;
428-
429- // In git mode, the toggle button is hidden, but the 't' shortcut calls .click() on it,
430- // which should still toggle the class
431- await expect ( toc ) . not . toHaveClass ( / t o c - h i d d e n / ) ;
432-
433- // Press t again to close
422+ // Press t — should be a no-op since TOC is hidden in git mode
434423 await page . keyboard . press ( 't' ) ;
435424 await expect ( toc ) . toHaveClass ( / t o c - h i d d e n / ) ;
436425 } ) ;
Original file line number Diff line number Diff line change 34453445 const tocEl = document . getElementById ( 'toc' ) ;
34463446 const listEl = tocEl . querySelector ( '.toc-list' ) ;
34473447 const toggleBtn = document . getElementById ( 'tocToggle' ) ;
3448+ const tocShortcut = document . querySelector ( '.shortcut-toc-only' ) ;
34483449 listEl . innerHTML = '' ;
34493450
3451+ function hideToc ( ) {
3452+ toggleBtn . style . display = 'none' ;
3453+ if ( tocShortcut ) tocShortcut . style . display = 'none' ;
3454+ }
3455+
34503456 // TOC only for single-file markdown reviews
34513457 if ( session . mode === 'git' || files . length > 1 ) {
3452- toggleBtn . style . display = 'none' ;
3458+ hideToc ( ) ;
34533459 return ;
34543460 }
34553461
34643470 }
34653471
34663472 if ( allItems . length === 0 ) {
3467- toggleBtn . style . display = 'none' ;
3473+ hideToc ( ) ;
34683474 return ;
34693475 }
34703476 toggleBtn . style . display = '' ;
3477+ if ( tocShortcut ) tocShortcut . style . display = '' ;
34713478
34723479 // Restore TOC open/closed state from cookie
34733480 if ( getCookie ( 'crit-toc' ) === 'open' ) {
38023809 break ;
38033810 }
38043811 case 't' : {
3812+ var tocBtn = document . getElementById ( 'tocToggle' ) ;
3813+ if ( tocBtn . style . display === 'none' ) return ;
38053814 e . preventDefault ( ) ;
3806- document . getElementById ( 'tocToggle' ) . click ( ) ;
3815+ tocBtn . click ( ) ;
38073816 break ;
38083817 }
38093818 case 'n' : {
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ <h3>Keyboard Shortcuts</h3>
110110 < tr class ="shortcut-filemode-only "> < td > < kbd > n</ kbd > </ td > < td > Next change</ td > </ tr >
111111 < tr class ="shortcut-filemode-only "> < td > < kbd > N</ kbd > </ td > < td > Previous change</ td > </ tr >
112112 < tr > < td > < kbd > Shift</ kbd > +< kbd > F</ kbd > </ td > < td > Finish review</ td > </ tr >
113- < tr > < td > < kbd > t</ kbd > </ td > < td > Toggle table of contents</ td > </ tr >
113+ < tr class =" shortcut-toc-only " > < td > < kbd > t</ kbd > </ td > < td > Toggle table of contents</ td > </ tr >
114114 < tr > < td > < kbd > Esc</ kbd > </ td > < td > Cancel / clear focus</ td > </ tr >
115115 < tr > < td > < kbd > Ctrl</ kbd > +< kbd > Enter</ kbd > </ td > < td > Submit comment</ td > </ tr >
116116 < tr > < td > < kbd > ?</ kbd > </ td > < td > Toggle this help</ td > </ tr >
You can’t perform that action at this time.
0 commit comments