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

#709: Lighthouse check: Cookiebanner ARIA #40

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions src/cookie-consent.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@
saveButtonText: Config().get("labels.aria.button"),
defaultButtonLabel: Config().get("labels.button.default"),
acceptAllButton:
Config().get("acceptAllButton")
&& !Preferences().hasPreferences(),
Config().get("acceptAllButton") && !Preferences().hasPreferences(),
};
// custom content from data-attributes
const customContent = {
Expand Down Expand Up @@ -122,10 +121,10 @@
this.tabList.init();

const template = `
<aside part="${this.config.prefix}" id="${this.config.prefix}" class="${this.config.prefix} js-cookie-bar" role="dialog" aria-live="polite" aria-describedby="${this.config.prefix}-description" aria-hidden="true" tabindex="0">
<aside part="${this.config.prefix}" id="${this.config.prefix}" class="${this.config.prefix} js-cookie-bar" role="dialog" aria-live="polite" aria-labelledby="${this.config.prefix}__title" aria-describedby="${this.config.prefix}-description" aria-hidden="true" tabindex="0">
<!--googleoff: all-->
<header part="${this.config.prefix}__header" class="${this.config.prefix}__header" id="${this.config.prefix}-description">
<h1 part="${this.config.prefix}__title">${this.data.title}</h1>
<h1 part="${this.config.prefix}__title" id="${this.config.prefix}__title">${this.data.title}</h1>
${this.data.description}
</header>
<form part="${this.config.prefix}__form">
Expand Down Expand Up @@ -186,9 +185,9 @@
const checkedCount = values.filter((v) => v.accepted).length;
const userOptionsChecked = checkedCount >= requiredCount;
if (
this.data.acceptAllButton
&& this.config.type === "checkbox"
&& !userOptionsChecked
this.data.acceptAllButton &&

Check failure on line 188 in src/cookie-consent.mjs

View workflow job for this annotation

GitHub Actions / CI (16)

'&&' should be placed at the beginning of the line

Check failure on line 188 in src/cookie-consent.mjs

View workflow job for this annotation

GitHub Actions / CI (18)

'&&' should be placed at the beginning of the line
this.config.type === "checkbox" &&

Check failure on line 189 in src/cookie-consent.mjs

View workflow job for this annotation

GitHub Actions / CI (16)

'&&' should be placed at the beginning of the line

Check failure on line 189 in src/cookie-consent.mjs

View workflow job for this annotation

GitHub Actions / CI (18)

'&&' should be placed at the beginning of the line
!userOptionsChecked
) {
return values.map((value) => ({
...value,
Expand Down Expand Up @@ -251,7 +250,8 @@
// Loop through arrayfiedTabListChildren
tabListChildren.forEach((input) => {
// Find all input elements
const inputElement = input.firstElementChild.firstElementChild.firstElementChild;
const inputElement =

Check failure on line 253 in src/cookie-consent.mjs

View workflow job for this annotation

GitHub Actions / CI (16)

There should be no line break before or after '='

Check failure on line 253 in src/cookie-consent.mjs

View workflow job for this annotation

GitHub Actions / CI (18)

There should be no line break before or after '='
input.firstElementChild.firstElementChild.firstElementChild;
// Loop through updated cookies
this.cookies.forEach((cookie) => {
// set the checked state to the updated cookie state
Expand Down
10 changes: 5 additions & 5 deletions src/dialog-tablist.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const DialogTabList = (cookieInformation) => {
transform: scaleY(-1);
}
</style>
<li part="${PREFIX}__tab-list-item" role="presentation">
<li part="${PREFIX}__tab-list-item" id="${PREFIX}-tab-${index}" aria-controls="${PREFIX}-tabpanel-${index}" role="tab">
<header part="${PREFIX}__tab" class="${PREFIX}__tab">
<label part="${PREFIX}__option" class="${PREFIX}__option" data-required="${required}">
<input
Expand All @@ -56,10 +56,8 @@ const DialogTabList = (cookieInformation) => {
<a
part="${PREFIX}__tab-toggle"
class="${PREFIX}__tab-toggle"
role="tab"
id="${PREFIX}-tab-${index}"
id="${PREFIX}-tab"
href="#${PREFIX}-tabpanel-${index}"
aria-controls="${PREFIX}-tabpanel-${index}"
aria-selected="false"
aria-label="${Config().get("labels.aria.tabToggle")}">
<svg part="${PREFIX}__tab-toggle-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 16"><path d="M21.5.5l3 3.057-12 11.943L.5 3.557 3.5.5l9 9z"/></svg>
Expand Down Expand Up @@ -95,7 +93,9 @@ const DialogTabList = (cookieInformation) => {
: undefined,
}));
return `
<ul part="${PREFIX}__tab-list" class="${PREFIX}__tab-list" role="tablist" aria-label="${Config().get("labels.aria.tabList")}">
<ul part="${PREFIX}__tab-list" id="${PREFIX}__tab-list" class="${PREFIX}__tab-list" role="tablist" aria-owns="${PREFIX}-tab" aria-label="${Config().get(
"labels.aria.tabList"
)}">
${cookiesWithState.map(renderTab).join("")}
</ul>
`;
Expand Down
Loading