Skip to content

JDK-8273034: Make javadoc navigation collapsible on small displays #5360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from

Conversation

hns
Copy link
Member

@hns hns commented Sep 3, 2021

Please review a change to add a collapsible "hamburger" navigation bar to javadoc pages for small screens. The collapsible navbar is activated when the browser width is below 920px, which is the point where the normal navigation bar starts to wrap for some javadoc pages.

The feature is implemented using CSS and JavaScript techniques employed by popular frameworks and has been successfully tested on several browsers and platforms, including various Android and iOS devices as well as IE and Edge browsers on Windows 10.

Sample documentation generated with this change is provided at the URL below. For testing, please review it on a mobile phone or tablet, or using the device emulation features provided with the developer tools of many desktop browsers.

http://cr.openjdk.java.net/~hannesw/8273034/api.00/index.html

One peculiarity of this change is that the sub-navigation links are rendered separately for the normal and the mobile navbar. The reason for this is that the links are structured differently (flat list vs nested lists) and reside in different containers.

On the CSS side, apart from the collapsible navbar I overhauled the styles for the search input, especially the small reset "X" button. The positioning of the reset button is now simpler and more robust by using absolute instead of relative position, and doesn't require moving the search input and label to the right anymore.

The collapsible menu uses the aria-controls, aria-expanded attributes as described in the following wiki page:

https://www.w3.org/WAI/GL/wiki/Using_the_WAI-ARIA_aria-expanded_state_to_mark_expandable_and_collapsible_regions

Furthermore, the aria-label attribute is used to provide a human-readable lable for the button.

https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-label_attribute


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8273034: Make javadoc navigation collapsible on small displays

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5360/head:pull/5360
$ git checkout pull/5360

Update a local copy of the PR:
$ git checkout pull/5360
$ git pull https://git.openjdk.java.net/jdk pull/5360/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5360

View PR using the GUI difftool:
$ git pr show -t 5360

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5360.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 3, 2021

👋 Welcome back hannesw! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 3, 2021
@openjdk
Copy link

openjdk bot commented Sep 3, 2021

@hns The following label will be automatically applied to this pull request:

  • javadoc

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the javadoc javadoc-dev@openjdk.org label Sep 3, 2021
@mlbridge
Copy link

mlbridge bot commented Sep 3, 2021

Webrevs

@pavelrappo
Copy link
Member

I haven't looked at the code yet. I've only seen the sample documentation on my laptop and my initial reaction was: Oh boy, does it look good! Both primary and secondary navigation is at your fingertips (no pun intended).

A few remarks.

  1. I don't expect this to be an issue on small devices and it's not a big deal, but might look better if fixed. When you try to resize the window in an expanded hamburger view, the view collapses. Compare this behavior with that of, for example, https://getbootstrap.com/.
  2. A problem which was highlighted by this change rather than brought by it, is that the primary navigation items (i.e. OVERVIEW, MODULE, PACKAGE, CLASS, USE, etc.) that are disabled (i.e. cannot be clicked) are indistinguishable from those that are enabled. Sure, if you have a pointing device such as a trackpad or mouse, you can hover over those items to see if they change their appearance. However, this does not seem achievable with your finger touching a phone screen.

@hns
Copy link
Member Author

hns commented Sep 6, 2021

Thanks for the feedback, Pavel! Both of the issues you spotted are very valid. I spent some time on both of them, but gave up for the time being since I didn't find a quick solution.

Regarding the menu collapsing when resizing the browser (only when changing browser width btw), avoiding this would have required either duplication of hard-coded values between the CSS and script files, or adding more complexity to the script than seemed reasonable to me. I haven't looked at how Bootstrap solves this particular problem, but I guess they are willing to go the extra mile since this is part of their core purpose. In the pursuit of simplicity and maintainability, I thought the closing behaviour was acceptable.

Regarding the same color being used for active and inactive links in the navigation bar, I tried to find a faded-out color for the inactive links, but it turned out that with the particular blue background any color but white is considered to break accessibility rules. We might want to file an separate issue for this.

Copy link
Contributor

@jonathan-gibbons jonathan-gibbons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only minor comments/questions

addListToNav(listContents, tree);
};
if (nested) {
tree.add(HtmlTree.LI(HtmlTree.P(label))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the HtmlTree.P necessary/useful?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is necessary, at least I haven't found an alternative solution.

The <li> element we are creating here contains the main label as well as a nested list of links. The <li> elements of the nested list are sized and padded via CSS. In order to apply similar size and padding to the main label it needs to be contained in an element with block display.

I realize the use of <p> instead of <div> may seem a bit strange as the label does not really represent a paragraph. I think I chose it because it had more useful default sizing rules. However, I could easily switch to using a <div> instead.

tree.add(li);
addListToNav(listContents, tree);
if (nested) {
Content li = HtmlTree.LI(HtmlTree.P(contents.detailLabel));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto: Is the HtmlTree.P necessary/useful?

@@ -291,6 +291,35 @@ function doSearch(request, response) {
response(result);
}
$(function() {
var expanded = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include standard/recurring discussion on testing JavaScript

ul.sub-nav-list-small li p {
margin: 5px 0;
}
div#navbar-sub-list {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to us:

The use of standard id's in the stylesheet should be documented in the upcoming new spec document

@@ -807,34 +807,113 @@ table.striped > tbody > tr > th {
font-weight: normal;
}
/**
* Tweak font sizes and paddings for small screens.
* Tweak style for small screens.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General comment, for discussion ...
There's a growing set of absolute values in the stylesheet. At what point should we generate the .css file from a template and a separate list of definitions?

HtmlTree ulNavSummaryRight = new HtmlTree(TagName.UL).setStyle(HtmlStyle.subNavListSmall);
addSummaryLinks(ulNavSummaryRight, true);
addDetailLinks(ulNavSummaryRight, true);
navDiv.add(ulNavSummaryRight);
tree.add(navDiv);

HtmlTree subDiv = new HtmlTree(TagName.DIV).setStyle(HtmlStyle.subNav);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should have some factory methods for HtmlTree.DIV

@openjdk
Copy link

openjdk bot commented Sep 22, 2021

@hns This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8273034: Make javadoc navigation collapsible on small displays

Reviewed-by: jjg

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 263 new commits pushed to the master branch:

  • 57fe11c: 8274120: [JVMCI] CompileBroker should resolve parameter types for JVMCI compiles
  • 81d4164: 8272759: (fc) java/nio/channels/FileChannel/Transfer2GPlus.java failed in timeout
  • da38ced: 8271602: Add Math.ceilDiv() family parallel to Math.floorDiv() family
  • d39aad9: 8273924: ArrayIndexOutOfBoundsException thrown in java.util.JapaneseImperialCalendar.add()
  • c9de806: 8274039: codestrings gtest fails when hsdis is present
  • 33df388: 8274003: ProcessHandleImpl.Info toString has an if check which is always true
  • 0a36163: 8272600: (test) Use native "sleep" in Basic.java
  • c6df3c9: 8274071: Clean up java.lang.ref comments and documentation
  • 71788c6: 8271287: jdk/jshell/CommandCompletionTest.java fails with "lists don't have the same size expected"
  • ba7d550: 8270139: jshell InternalError crash for import of @repeatable followed by unresolved ref
  • ... and 253 more: https://git.openjdk.java.net/jdk/compare/02822e1398d6015f0ed26edd440db8e0d50bf152...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 22, 2021
@hns
Copy link
Member Author

hns commented Sep 24, 2021

/integrate

@openjdk
Copy link

openjdk bot commented Sep 24, 2021

Going to push as commit 1d44014.
Since your change was applied there have been 285 commits pushed to the master branch:

  • bb74ae8: 8274171: java/nio/file/Files/probeContentType/Basic.java failed on "Content type" mismatches
  • 56b8b35: 8273261: Replace 'while' cycles with iterator with enhanced-for in java.base
  • 0aa63fe: 8274216: ProblemList 2 serviceability/dcmd/gc tests with ZGC on linux-all and windows-all
  • 5ffbe75: 8274195: Doc cleanup in java.nio.file
  • 1fdc656: 8274175: (fc) java/nio/channels/FileChannel/Transfer2GPlus.java still failed in timeout
  • 3b1b8fc: 8269850: Most JDK releases report macOS version 12 as 10.16 instead of 12.0
  • 1b7f4b7: 8274169: HotSpot Style Guide has stale link to chromium style guide
  • 653a612: 8270156: Add "randomness" and "stress" keys to JTreg tests which use StressGCM, StressLCM and/or StressIGVN
  • 66ce09f: 8272703: StressSeed should be set via FLAG_SET_ERGO
  • c434528: 8273546: DecimalFormat documentation contains literal HTML character references
  • ... and 275 more: https://git.openjdk.java.net/jdk/compare/02822e1398d6015f0ed26edd440db8e0d50bf152...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Sep 24, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 24, 2021
@openjdk
Copy link

openjdk bot commented Sep 24, 2021

@hns Pushed as commit 1d44014.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated javadoc javadoc-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

3 participants