-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
report: quick tab #9175
report: quick tab #9175
Changes from 3 commits
e7560c6
3ccf02e
55008b7
9a7df73
8b49ef6
15bfaf1
cf10dd8
ccc083c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,7 @@ class ReportUIFeatures { | |
this._setupToolsButton(); | ||
this._setupThirdPartyFilter(); | ||
this._setUpCollapseDetailsAfterPrinting(); | ||
this._setUpQuickTabFocus(); | ||
this._resetUIState(); | ||
this._document.addEventListener('keyup', this.onKeyUp); | ||
this._document.addEventListener('copy', this.onCopy); | ||
|
@@ -559,6 +560,40 @@ class ReportUIFeatures { | |
} | ||
} | ||
|
||
/** | ||
* Tab + Enter for quick jump document.activeElement to the first interesting element. | ||
*/ | ||
_setUpQuickTabFocus() { | ||
const firstContentSelectors = [ | ||
{ | ||
selector: '.lh-audit--fail summary', | ||
label: 'Jump to first failing audit.', | ||
}, | ||
{ | ||
selector: '.lh-audit--average summary', | ||
label: 'Jump to first average audit.', | ||
}, | ||
{ | ||
selector: '.lh-audit--audit summary', | ||
label: 'Jump to first audit.', | ||
}, | ||
]; | ||
|
||
const {selector, label} = firstContentSelectors.find(({selector}) => { | ||
const el = this._document.querySelector(selector); | ||
return Boolean(el && el instanceof HTMLElement); | ||
}) || {selector: '.lh-category-header .lh-gauge__wrapper', label: 'Jump to first category.'}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not just put this last in the array? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because this asserts that the variable will always be non-null (if find returns null, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems like sort of a roundabout way of asserting that :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair - I refactored it. |
||
|
||
const startOfContentEl = this._dom.find(selector, this._document); | ||
const quickFocusEl = this._dom.find('.lh-a11y-quick-focus', this._document); | ||
quickFocusEl.textContent = label; | ||
quickFocusEl.classList.remove('disabled'); | ||
quickFocusEl.addEventListener('click', (e) => { | ||
startOfContentEl.focus(); | ||
e.preventDefault(); | ||
}); | ||
} | ||
|
||
/** | ||
* Returns the html that recreates this report. | ||
* @return {string} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -352,8 +352,32 @@ | |
margin-left: 0; | ||
} | ||
} | ||
|
||
.lh-a11y-quick-focus { | ||
background-color: var(--color-blue); | ||
color: var(--color-white); | ||
padding: 20px; | ||
clip: rect(1px, 1px, 1px, 1px); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why clip? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. Here's a bad answer: I took it straight from GitHub.
|
||
margin: 0; | ||
height: 1px; | ||
width: 1px; | ||
overflow: hidden; | ||
position: absolute; | ||
} | ||
.lh-a11y-quick-focus.disabled { | ||
visibility: hidden; | ||
} | ||
.lh-a11y-quick-focus:focus { | ||
clip: auto; | ||
height: auto; | ||
width: auto; | ||
z-index: 10000; /* lol */ | ||
} | ||
</style> | ||
|
||
<!-- This is disabled by default. Enabled in ReportUIFeatures. --> | ||
<a href="#" class="lh-a11y-quick-focus disabled" tabindex="1"></a> | ||
|
||
<div class="lh-topbar"> | ||
<!-- Flat Lighthouse logo. --> | ||
<svg class="lh-topbar__logo" viewBox="0 0 192 192"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol this
setUp
typo has survived a full 2 years https://github.com/GoogleChrome/lighthouse/pull/2000/filesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhhhh now I can't unsee.