Skip to content

Commit 50b0c0e

Browse files
danilsomsikovDevtools-frontend LUCI CQ
authored andcommitted
Improve the a11y of the 3-dots menu and the rest of the LH report
https://screencast.googleplex.com/cast/NjcyNjcxNjU5OTgyODQ4MHxiZDU0ZWM0Yy01OQ Bug: 40272029 Change-Id: I6f125b6b9e4a6f691e8028fd9bcd11fefd77aa5d Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7261896 Reviewed-by: Connor Clark <cjamcl@chromium.org> Auto-Submit: Danil Somsikov <dsv@chromium.org> Commit-Queue: Danil Somsikov <dsv@chromium.org>
1 parent 5e129ae commit 50b0c0e

File tree

2 files changed

+56
-3
lines changed

2 files changed

+56
-3
lines changed

front_end/panels/lighthouse/LighthousePanel.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export class LighthousePanel extends UI.Panel.Panel {
104104

105105
this.renderToolbar();
106106
this.auditResultsElement = this.contentElement.createChild('div', 'lighthouse-results-container');
107+
this.auditResultsElement.addEventListener('keydown', this.onKeyDown.bind(this));
107108
this.renderStartView();
108109

109110
this.controller.recomputePageAuditability();
@@ -365,4 +366,13 @@ export class LighthousePanel extends UI.Panel.Panel {
365366
}
366367
return els;
367368
}
369+
370+
private onKeyDown(event: KeyboardEvent): void {
371+
// The LHR's tool button is a toggle. When the user hits escape, the default behavior
372+
// is to close the tool drawer. We want to prevent this behavior and instead let the
373+
// LHR's tool button handle the event and close the tool's dropdown.
374+
if (event.key === 'Escape' && this.auditResultsElement.querySelector('.lh-tools__button.lh-active')) {
375+
event.handled = true;
376+
}
377+
}
368378
}

front_end/panels/lighthouse/lighthousePanel.css

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ button.view-trace {
1919
margin: 10px;
2020
}
2121

22-
.lighthouse-results-container {
23-
position: relative;
24-
}
2522
/** `window.opener` is null for windows opened from DevTools. This breaks
2623
the LH viewer app, so disable this feature. */
2724

@@ -63,3 +60,49 @@ select.lighthouse-report {
6360
.lh-devtools .lh-element-screenshot__overlay {
6461
position: absolute;
6562
}
63+
64+
.lighthouse-results-container {
65+
position: relative;
66+
67+
:focus-visible {
68+
outline: -webkit-focus-ring-color auto 1px;
69+
}
70+
71+
.lh-tools__button {
72+
height: var(--sys-size-9);
73+
width: var(--sys-size-9);
74+
min-width: var(--sys-size-9);
75+
76+
&:focus-visible {
77+
border-radius: var(--sys-shape-corner-full);
78+
outline: var(--sys-size-2) solid var(--sys-color-state-focus-ring);
79+
}
80+
81+
&.lh-active + .lh-tools__dropdown {
82+
clip: rect(-8px, 204px, 270px, -10px); /* stylelint-disable-line property-no-deprecated */
83+
}
84+
}
85+
86+
.lh-tools__dropdown {
87+
padding: var(--sys-size-5) 0;
88+
border-radius: var(--sys-shape-corner-small);
89+
box-shadow: var(--sys-elevation-level3);
90+
top: 24px;
91+
92+
&:hover a:focus {
93+
background-color: transparent;
94+
}
95+
96+
a {
97+
height: var(--sys-size-11);
98+
padding: 0 var(--sys-size-8);
99+
white-space: nowrap;
100+
align-items: center;
101+
102+
&::before {
103+
content: none;
104+
}
105+
}
106+
}
107+
108+
}

0 commit comments

Comments
 (0)