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

fix(Accessibility): on column item selection screen reader should read the newly added preview column content #298

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions coral-component-columnview/src/scripts/ColumnView.js
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for this behavior?

Original file line number Diff line number Diff line change
Expand Up @@ -991,16 +991,22 @@ const ColumnView = Decorator(class extends BaseComponent(HTMLElement) {
const addedNodesCount = addedNodes.length;
for (let i = 0 ; i < addedNodesCount ; i++) {
item = addedNodes[i];
if (this.activeItem) {
let activeOrSelectedItem;
if (this.selectedItems.length === 1 && this.selectedItem){
activeOrSelectedItem = this.selectedItem;
} else if (this.activeItem){
activeOrSelectedItem = this.activeItem;
}
if (activeOrSelectedItem) {
// @a11y add aria-owns attribute to active item to express relationship of added column to the active item
this.activeItem.setAttribute('aria-owns', item.id);
this.activeOrSelectedItem.setAttribute('aria-owns', item.id);

// @a11y column or preview should be labelled by active item
item.setAttribute('aria-labelledby', this.activeItem.content.id);
item.setAttribute('aria-labelledby', this.activeOrSelectedItem.content.id);

// @a11y preview should provide description for active item
if (item.tagName === 'CORAL-COLUMNVIEW-PREVIEW') {
this.activeItem.setAttribute('aria-describedby', item.id);
this.activeOrSelectedItem.setAttribute('aria-describedby', item.id);
}
}

Expand Down