-
Notifications
You must be signed in to change notification settings - Fork 213
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
feat: upgrade accessibility of tab/tab-list family of elements #296
Conversation
fe1fdb5
to
15aef53
Compare
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.
Looks good except for the orientation issues.
Found an unrelated issue where focus gets lost when selecting tabs on iOS w/ Voiceover but not related to this PR so will file a new issue.
packages/tab-list/src/tab-list.ts
Outdated
|
||
public handleKeydown(event: KeyboardEvent): void { | ||
const { code } = event; | ||
if (code !== 'ArrowLeft' && code !== 'ArrowRight') { |
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.
Vertical Tabs need to handle ArrowUp and ArrowDown
@@ -72,6 +75,34 @@ export class TabList extends LitElement { | |||
`; | |||
} | |||
|
|||
protected firstUpdated(): void { | |||
this.setAttribute('role', 'tablist'); |
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.
Need to set aria-orientation="vertical"
for a vertical tab list (no need to set for horizontal)
Now with |
c3bd018
to
6503fb2
Compare
817cf44
to
5710b5b
Compare
Looks great functionally, just a minor styling thing. In
Our implementation of the selection indicator deviates from spectrum-css, where it's represented by the Maybe not in scope for this PR, would be cool to get the right focus styles for the indicator sometime down the line |
5545c7b
to
4a66ed0
Compare
4a66ed0
to
996ebd5
Compare
996ebd5
to
c8b1f06
Compare
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.
@andrewhatran This is actually a great catch here! Thanks for being vigilant. Take a look at my other notes to see what went down, but I think things are in a much better place for this PR now!
node.value === '::before' || | ||
node.value === '::after' | ||
node.value.match(/before$/) !== null || | ||
node.value.match(/after$/) !== null |
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.
Spectrum CSS changed from ::before
to :before
and broke the processing here. End with before
should make us resilient to similar variances in the future and this is a build task, so it shouldn't effect performance to use regex.
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.
Ahh that looks annoying, thanks for making this more robust 👍
@@ -82,7 +82,8 @@ export class Focusable extends FocusVisiblePolyfillMixin(LitElement) { | |||
} | |||
} | |||
|
|||
protected firstUpdated(): void { | |||
protected firstUpdated(changes: PropertyValues): void { |
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.
Wasn't extendable without this.
this.querySelector('sp-tab')) as Tab; | ||
} | ||
|
||
protected manageAutoFocus(): void { |
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.
Wait till all of the child items are ready before trying to focus on one of them.
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.
The focus styles look great now, thanks for making that change!
Description
Manage
role
andtabindex
values in<sp-tab>
and<sp-tab-list>
elements. Take multiple<sp-tab>
elements out of the tab order and make them accessible via arrow keys. Support similar coverage for the[direction="vertical"]
variant.Follow up
Looking deeper into this pattern, I wonder if we want to support a
<sp-tab-panels>
style component in the future that takes<sp-tab-panel>
elements and uses the attributes/properties thereof to build an<sp-tab-list>
element dynamically. 🤔Related Issue
refs #292
Motivation and Context
Things should be accessible.
How Has This Been Tested?
Types of changes
Checklist: