Skip to content
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

Improve breadcrumb bar accessibility #6912

Merged
merged 34 commits into from
Oct 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7f5f951
Init
janfaracik Jul 11, 2022
cf779ed
Update core/src/main/resources/lib/layout/breadcrumb.jelly
janfaracik Jul 12, 2022
ec7e8c5
Update attribute name
janfaracik Jul 12, 2022
5dc14bd
Merge branch 'master' into update-breadcrumbs
janfaracik Jul 12, 2022
af15121
Merge branch 'master' into update-breadcrumbs
janfaracik Jul 12, 2022
0e6738c
Add back missing slash
janfaracik Jul 12, 2022
e044f36
Update core/src/main/resources/lib/layout/breadcrumb.jelly
janfaracik Jul 13, 2022
17a9a63
Init
janfaracik Jul 14, 2022
ac488cb
Init
janfaracik Jul 14, 2022
d0679a4
Remove stylings
janfaracik Jul 14, 2022
a50f38b
Merge branch 'master' into update-breadcrumb-2
janfaracik Jul 19, 2022
9e51f38
Fix breadcrumb dropdowns, remove separator hover
janfaracik Jul 20, 2022
b10d355
Update top sticker
janfaracik Jul 20, 2022
4c159d4
Merge branch 'master' into update-breadcrumb-2
janfaracik Jul 22, 2022
bfc95fa
Potential fix for sidebar child breadcrumbs
janfaracik Jul 23, 2022
db8e8dd
Merge branch 'master' into update-breadcrumb-2
janfaracik Jul 24, 2022
dea8373
Merge branch 'master' into update-breadcrumb-2
janfaracik Jul 24, 2022
e09638d
Update HudsonTest.java
janfaracik Jul 24, 2022
d081079
Update page.js
janfaracik Jul 24, 2022
f8d3330
Update page.js
janfaracik Jul 24, 2022
ad891dd
Fix test
janfaracik Jul 24, 2022
781c76b
Update footer styling
janfaracik Jul 25, 2022
e721049
Merge branch 'master' into update-breadcrumb-2
janfaracik Aug 10, 2022
df5e2f5
Merge branch 'master' into update-breadcrumb-2
janfaracik Aug 11, 2022
4c20016
Merge branch 'master' into update-breadcrumb-2
timja Aug 16, 2022
bc23ca2
Merge branch 'master' into update-breadcrumb-2
timja Aug 17, 2022
7e9ec8a
Merge remote-tracking branch 'origin/master' into update-breadcrumb-2
basil Aug 25, 2022
7578f91
Merge branch 'master' into update-breadcrumb-2
janfaracik Sep 1, 2022
fcf1221
Restore last breadcrumb if it is clickable
janfaracik Sep 1, 2022
5ee18d4
Merge branch 'master' into update-breadcrumb-2
janfaracik Sep 26, 2022
72aa819
Add aria labels to breadcrumb bar and current item
janfaracik Sep 26, 2022
94e67bf
Update breadcrumbs.less
janfaracik Sep 27, 2022
3f25aeb
Merge branch 'master' into update-breadcrumb-2
janfaracik Sep 27, 2022
f8314a1
Merge branch 'master' into update-breadcrumb-2
NotMyFault Oct 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/src/main/resources/hudson/model/Job/configure.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ THE SOFTWARE.
<script src="${resURL}/jsbundles/section-to-sidebar-items.js" type="text/javascript" defer="true" />
</l:header>

<l:breadcrumb title="${%Configuration}" />

<l:side-panel>
<l:app-bar title="${%Configure}" />
<div id="tasks" />
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/resources/lib/layout/breadcrumb.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ THE SOFTWARE.
</st:documentation>

<j:if test="${mode=='breadcrumbs'}">
<li id="${attrs.id}" class="item">
<j:set var="hasLink" value="${!(attrs.href == null or h.hyperlinkMatchesCurrentPage(attrs.href))}" />
<li id="${attrs.id}" class="jenkins-breadcrumbs__list-item" aria-current="${hasLink ? null : 'page'}">
<j:choose>
<j:when test="${attrs.href == null}">
<j:when test="${!hasLink}">
${attrs.title}
</j:when>
<j:otherwise>
Expand Down
58 changes: 29 additions & 29 deletions core/src/main/resources/lib/layout/breadcrumbBar.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -37,36 +37,36 @@ THE SOFTWARE.

<st:adjunct includes="lib.layout.breadcrumbs" />

<div class="top-sticker noedge">
<div class="top-sticker-inner">
<div class="jenkins-breadcrumbs">
<ul id="breadcrumbs">
<j:forEach var="anc" items="${request.ancestors}">
<j:if test="${h.isModel(anc.object) and anc.prev.url!=anc.url}">
<j:set var="mode" value="breadcrumbs" />
<l:breadcrumb title="${anc.object == app ? '%Dashboard' : anc.object.displayName}"
href="${anc.url}/"
hasMenu="${h.isModelWithContextMenu(anc.object)}" />
<j:choose>
<j:when test="${h.isModelWithChildren(anc.object)}">
<li class="children" href="${anc.url}/">
<!-- shows '>' for rendering children -->
</li>
</j:when>
<j:otherwise>
<li class="separator">
</li>
</j:otherwise>
</j:choose>
</j:if>
</j:forEach>
<j:set var="contents" trim="true">
<d:invokeBody />
</j:set>

<!-- render additional breadcrumb items -->
<d:invokeBody />
</ul>
<div id="breadcrumbBar" class="jenkins-breadcrumbs" aria-label="breadcrumb">
<ol class="jenkins-breadcrumbs__list" id="breadcrumbs">
<j:forEach var="anc" items="${request.ancestors}" indexVar="index">
<j:if test="${h.isModel(anc.object) and anc.prev.url!=anc.url}">
<j:set var="mode" value="breadcrumbs" />
<l:breadcrumb title="${anc.object == app ? '%Dashboard' : anc.object.displayName}"
href="${contents.length() == 0 and (index == request.ancestors.size() - 1) ? null : anc.url + '/'}"
hasMenu="${h.isModelWithContextMenu(anc.object)}" />
<j:choose>
<j:when test="${h.isModelWithChildren(anc.object)}">
<li class="children" href="${anc.url}/">
<!-- shows '>' for rendering children -->
</li>
</j:when>
<j:otherwise>
<li class="separator">
</li>
</j:otherwise>
</j:choose>
</j:if>
</j:forEach>

<div id="breadcrumb-menu-target"/><!-- this is where the menu gets rendered -->
</div>
</div>
<!-- render additional breadcrumb items -->
<j:out value="${contents}" />
</ol>
</div>

<div id="breadcrumb-menu-target"/><!-- this is where the menu gets rendered -->
</j:jelly>
10 changes: 4 additions & 6 deletions core/src/main/resources/lib/layout/layout.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,10 @@ THE SOFTWARE.
searchHelpUrl="${%searchBox.url}"
logout="${%logout}"/>

<div id="breadcrumbBar">
<l:breadcrumbBar>
<j:set var="mode" value="breadcrumbs" />
<d:invokeBody/>
</l:breadcrumbBar>
</div>
<l:breadcrumbBar>
<j:set var="mode" value="breadcrumbs" />
<d:invokeBody/>
</l:breadcrumbBar>
</j:if>

<div id="page-body" class="app-page-body app-page-body--${layoutType} clear">
Expand Down
3 changes: 1 addition & 2 deletions test/src/test/java/hudson/model/HudsonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebRequest;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.DomNodeUtil;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
Expand Down Expand Up @@ -151,7 +150,7 @@ public void searchIndex() throws Exception {
public void breadcrumb() throws Exception {
HtmlPage root = j.createWebClient().goTo("");
DomElement navbar = root.getElementById("breadcrumbs");
assertEquals(1, DomNodeUtil.selectNodes(navbar, "LI/A").size());
assertEquals(1, navbar.querySelectorAll(".jenkins-breadcrumbs__list-item").size());
}

/**
Expand Down
10 changes: 4 additions & 6 deletions war/src/main/js/util/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ function onWinScroll(callback) {
}

function pageHeaderHeight() {
return elementHeight("#page-header") + breadcrumbBarHeight();
return (
document.querySelector("#page-header").offsetHeight + breadcrumbBarHeight()
);
}

function breadcrumbBarHeight() {
return elementHeight("#breadcrumbBar");
return document.querySelector("#breadcrumbBar").offsetHeight;
}

function removeTextHighlighting(selector) {
Expand All @@ -56,10 +58,6 @@ function removeTextHighlighting(selector) {
});
}

function elementHeight(selector) {
return $(selector).height();
}

export default {
onload,
winScrollTop,
Expand Down
10 changes: 5 additions & 5 deletions war/src/main/less/abstracts/theme.less
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@
// Header dimensions
--header-item-border-radius: 4px;

// Breadcrumbs and footer
--breadcrumbs-bg: #f8f8f8;
janfaracik marked this conversation as resolved.
Show resolved Hide resolved
--breadcrumbs-border: var(--light-grey);
--breadcrumbs-text-color: #4d545d;
--breadcrumbs-item-bg-color--hover: var(--light-grey);
// Breadcrumbs bar
--breadcrumbs-bar-background: hsla(240, 0.2, 0.965, 0.8);

// Footer
--footer-background: hsla(240, 0.2, 0.965, 0.8);

// Alert call outs
--alert-success-text-color: #155724;
Expand Down
4 changes: 0 additions & 4 deletions war/src/main/less/base/layout-commons.less
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ body {
margin-left: 0.25rem;
}

#footer-container {
background-color: var(--breadcrumbs-bg);
}

/* -------------------------------------- */

.app-page-body {
Expand Down
14 changes: 0 additions & 14 deletions war/src/main/less/base/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -515,20 +515,6 @@ pre.console {
}
}

.top-sticker,
#top-sticker {
width: 100%; /* it needs to occupy the entire width or else the underlying content will see through */
z-index: 999;
}

.top-sticker.noedge > .top-sticker-edge {
display: none;
}

.top-sticker.noedge > .top-sticker-inner {
padding: 0;
}

.icon16x16 {
width: 16px;
height: 16px;
Expand Down
77 changes: 43 additions & 34 deletions war/src/main/less/modules/breadcrumbs.less
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
#breadcrumbBar {
.jenkins-breadcrumbs {
position: sticky;
top: 0;
z-index: 999;
}

.jenkins-breadcrumbs {
display: flex;
align-items: center;
padding: 0.5rem 0.7rem 0.5rem 0.75rem;
padding: 0.55rem 0.7rem 0.55rem 0.75rem;
backdrop-filter: blur(15px);
overflow-x: auto;
background: var(--breadcrumbs-bar-background);

&::before {
content: "";
position: absolute;
inset: 0;
background: var(--table-background);
opacity: 0.95;
}

& > ul {
display: flex;
align-items: center;
&__list {
display: contents;
list-style-type: none;
margin: 0;
padding: 0;
flex: 1;
flex-wrap: wrap;
z-index: 0;

& > li {
& > * {
flex-shrink: 0;
}

&-item {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
color: var(--text-color);
font-weight: 500;
font-size: 0.85rem;
Expand All @@ -45,14 +37,22 @@
font-size: inherit;
margin: 0;
padding: 0;
color: inherit;
color: var(--text-color);
text-decoration: none;
margin-right: 0 !important;
transition: var(--standard-transition);

&::before,
&::after {
inset: -0.25rem -0.6rem;
}

&:hover,
&:active,
&:focus,
&:focus-visible {
color: var(--text-color);
}
}

& > .model-link {
Expand All @@ -70,9 +70,9 @@
.children,
.separator {
position: relative;
width: 14px;
height: 14px;
margin: 6px;
width: 1rem;
height: 1rem;
margin: 0.375rem 0.2rem;

&::after {
content: "";
Expand All @@ -81,10 +81,16 @@
left: 0;
bottom: 0;
right: 0;
opacity: 0.5;
transition: var(--standard-transition);
background: var(--text-color);
background: var(--text-color-secondary);
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'%3E%3Ctitle%3EChevron Forward%3C/title%3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M184 112l144 144-144 144'/%3E%3C/svg%3E");
opacity: 0.6;
}
}

.separator {
&:last-of-type {
display: none;
}
}

Expand All @@ -105,6 +111,15 @@
}
}

&:hover,
&:active,
&:focus,
&:focus-visible {
&::after {
background: var(--text-color);
}
}

// Increase the hit target
&::before {
content: "";
Expand All @@ -116,12 +131,6 @@
background: transparent;
}
}

.separator {
&:last-of-type {
display: none;
}
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions war/src/main/less/modules/page-footer.less
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
@import url("../abstracts/theme.less");

.page-footer {
background-color: var(--breadcrumbs-bg);
border-top: 1px solid var(--breadcrumbs-border);
background-color: var(--footer-background);
width: 100%;
clear: both;
font-size: var(--font-size-sm);
Expand Down
2 changes: 1 addition & 1 deletion war/src/main/webapp/scripts/hudson-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -2272,7 +2272,7 @@ function ensureVisible(e) {
}

// if there are any stickers around, subtract them from the viewport
handleStickers("top-sticker", function (t) {
handleStickers("jenkins-breadcrumbs", function (t) {
t = t.clientHeight;
Y += t;
H -= t;
Expand Down