@@ -350,21 +350,28 @@ private void addMainNavLinks(Content tree) {
350
350
* Adds the summary links to the sub-navigation.
351
351
*
352
352
* @param tree the content tree to which the sub-navigation will added
353
+ * @param nested whether to create a flat or nested list
353
354
*/
354
- private void addSummaryLinks (Content tree ) {
355
+ private void addSummaryLinks (Content tree , boolean nested ) {
355
356
switch (documentedPage ) {
356
357
case MODULE , PACKAGE , CLASS , HELP -> {
357
358
List <? extends Content > listContents = subNavLinks .getSubNavLinks ()
358
359
.stream ().map (HtmlTree ::LI ).toList ();
359
360
if (!listContents .isEmpty ()) {
360
- tree . add ( HtmlTree . LI ( switch (documentedPage ) {
361
+ Content label = switch (documentedPage ) {
361
362
case MODULE -> contents .moduleSubNavLabel ;
362
363
case PACKAGE -> contents .packageSubNavLabel ;
363
364
case CLASS -> contents .summaryLabel ;
364
365
case HELP -> contents .helpSubNavLabel ;
365
366
default -> Text .EMPTY ;
366
- }).add (Entity .NO_BREAK_SPACE ));
367
- addListToNav (listContents , tree );
367
+ };
368
+ if (nested ) {
369
+ tree .add (HtmlTree .LI (HtmlTree .P (label ))
370
+ .add (new HtmlTree (TagName .UL ).add (listContents )));
371
+ } else {
372
+ tree .add (HtmlTree .LI (label ).add (Entity .NO_BREAK_SPACE ));
373
+ addListToNav (listContents , tree );
374
+ }
368
375
}
369
376
}
370
377
}
@@ -374,8 +381,9 @@ private void addSummaryLinks(Content tree) {
374
381
* Adds the detail links to sub-navigation.
375
382
*
376
383
* @param tree the content tree to which the links will be added
384
+ * @param nested whether to create a flat or nested list
377
385
*/
378
- private void addDetailLinks (Content tree ) {
386
+ private void addDetailLinks (Content tree , boolean nested ) {
379
387
if (documentedPage == PageMode .CLASS ) {
380
388
List <Content > listContents = new ArrayList <>();
381
389
VisibleMemberTable vmt = configuration .getVisibleMemberTable ((TypeElement ) element );
@@ -394,10 +402,16 @@ private void addDetailLinks(Content tree) {
394
402
}
395
403
}
396
404
if (!listContents .isEmpty ()) {
397
- Content li = HtmlTree .LI (contents .detailLabel );
398
- li .add (Entity .NO_BREAK_SPACE );
399
- tree .add (li );
400
- addListToNav (listContents , tree );
405
+ if (nested ) {
406
+ Content li = HtmlTree .LI (HtmlTree .P (contents .detailLabel ));
407
+ li .add (new HtmlTree (TagName .UL ).add (listContents ));
408
+ tree .add (li );
409
+ } else {
410
+ Content li = HtmlTree .LI (contents .detailLabel );
411
+ li .add (Entity .NO_BREAK_SPACE );
412
+ tree .add (li );
413
+ addListToNav (listContents , tree );
414
+ }
401
415
}
402
416
}
403
417
}
@@ -605,9 +619,17 @@ public Content getContent() {
605
619
606
620
HtmlTree navDiv = new HtmlTree (TagName .DIV );
607
621
Content skipNavLinks = contents .getContent ("doclet.Skip_navigation_links" );
622
+ String toggleNavLinks = configuration .getDocResources ().getText ("doclet.Toggle_navigation_links" );
608
623
tree .add (MarkerComments .START_OF_TOP_NAVBAR );
609
624
navDiv .setStyle (HtmlStyle .topNav )
610
625
.setId (HtmlIds .NAVBAR_TOP )
626
+ .add (new HtmlTree (TagName .BUTTON ).setId (HtmlIds .NAVBAR_TOGGLE_BUTTON )
627
+ .put (HtmlAttr .ARIA_CONTROLS , HtmlIds .NAVBAR_TOP .name ())
628
+ .put (HtmlAttr .ARIA_EXPANDED , String .valueOf (false ))
629
+ .put (HtmlAttr .ARIA_LABEL , toggleNavLinks )
630
+ .add (HtmlTree .SPAN (HtmlStyle .navBarToggleIcon , HtmlTree .EMPTY ))
631
+ .add (HtmlTree .SPAN (HtmlStyle .navBarToggleIcon , HtmlTree .EMPTY ))
632
+ .add (HtmlTree .SPAN (HtmlStyle .navBarToggleIcon , HtmlTree .EMPTY )))
611
633
.add (HtmlTree .DIV (HtmlStyle .skipNav ,
612
634
links .createLink (HtmlIds .SKIP_NAVBAR_TOP , skipNavLinks ,
613
635
skipNavLinks .toString ())));
@@ -622,18 +644,22 @@ public Content getContent() {
622
644
.put (HtmlAttr .TITLE , rowListTitle );
623
645
addMainNavLinks (navList );
624
646
navDiv .add (navList );
647
+ HtmlTree ulNavSummaryRight = new HtmlTree (TagName .UL ).setStyle (HtmlStyle .subNavListSmall );
648
+ addSummaryLinks (ulNavSummaryRight , true );
649
+ addDetailLinks (ulNavSummaryRight , true );
650
+ navDiv .add (ulNavSummaryRight );
625
651
tree .add (navDiv );
626
652
627
653
HtmlTree subDiv = new HtmlTree (TagName .DIV ).setStyle (HtmlStyle .subNav );
628
654
629
- HtmlTree div = new HtmlTree (TagName .DIV );
655
+ HtmlTree div = new HtmlTree (TagName .DIV ). setId ( HtmlIds . NAVBAR_SUB_LIST ) ;
630
656
// Add the summary links if present.
631
657
HtmlTree ulNavSummary = new HtmlTree (TagName .UL ).setStyle (HtmlStyle .subNavList );
632
- addSummaryLinks (ulNavSummary );
658
+ addSummaryLinks (ulNavSummary , false );
633
659
div .add (ulNavSummary );
634
660
// Add the detail links if present.
635
661
HtmlTree ulNavDetail = new HtmlTree (TagName .UL ).setStyle (HtmlStyle .subNavList );
636
- addDetailLinks (ulNavDetail );
662
+ addDetailLinks (ulNavDetail , false );
637
663
div .add (ulNavDetail );
638
664
subDiv .add (div );
639
665
0 commit comments