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

SHS-6103: ARIA - "ARIA attribute unsupported or prohibited" in Vertical Timelines #1766

Open
wants to merge 3 commits into
base: 11.8.1-release
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

{% if description %}
<details {{ attributes }} open>
<summary class="hb-timeline-item__summary" aria-expanded="true" aria-pressed="true">
<summary class="hb-timeline-item__summary">
<div class="hb-timeline-item__heading">
{{ summary }}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
context,
);

// Find timeline items are are open inside of timelineCollapsed and close them!
// Find timeline items that are open inside of timelineCollapsed and close them!
timelineCollapsed.forEach((timeline) => {
// Find all the timeline items inside of the collapsed timeline
const items = timeline.querySelectorAll('.hb-timeline-item');
Expand All @@ -19,46 +19,10 @@
items.forEach((item) => {
item.removeAttribute('open');
});

// Find the summary element and update the aria attribute values
const summaries = timeline.querySelectorAll(
'.hb-timeline-item__summary',
);

summaries.forEach((summary) => {
summary.setAttribute('aria-expanded', 'false');
summary.setAttribute('aria-pressed', 'false');
});
});

// When a user clicks on a timeline, update the aria properties accordingly
const timelineItems = once('timeline-item', '.hb-timeline-item', context);

if (timelineItems) {
timelineItems.forEach((timelineItem) => {
const summary = timelineItem.querySelector(
'.hb-timeline-item__summary',
);

// Find the value of aria-expanded for a timeline item summary
let ariaExpanded = summary.getAttribute('aria-expanded');

// Update aria values!
summary.addEventListener(('keypress', 'click'), () => {
if (ariaExpanded === 'true') {
summary.setAttribute('aria-expanded', 'false');
summary.setAttribute('aria-pressed', 'false');
} else {
summary.setAttribute('aria-expanded', 'true');
summary.setAttribute('aria-pressed', 'true');
}

// Retain updated value for the aria-expanded attribute
ariaExpanded = summary.getAttribute('aria-expanded');
});
});
}

const searchQuery = new URLSearchParams(window.location.search);
const params = Object.fromEntries(searchQuery.entries());

Expand All @@ -67,10 +31,7 @@

timelineItems.forEach((timeline) => {
if (timeline.textContent.toLowerCase().includes(searchTerm)) {
const summary = timeline.querySelector('summary');
timeline.setAttribute('open', '');
summary.setAttribute('aria-expanded', 'true');
summary.setAttribute('aria-pressed', 'true');
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
transition: transform 150ms ease-in-out;
}

[aria-expanded="true"] & {
[open] & {
&::after {
transform: scaleY(-1);
}
Expand Down