-
Notifications
You must be signed in to change notification settings - Fork 229
docs(tab): update tab docs and a11y #5586
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
base: main
Are you sure you want to change the base?
Conversation
|
📚 Branch Preview🔍 Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
Tachometer resultsCurrently, no packages are changed by this PR... |
@aramos-adobe before adding the |
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.
Some minor changes, but overall all looking good. I like the details you've added to the docs.
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.
Nice work on this! I think there's some documentation changes that need to be made to clear up the focused state section. To me, they conflicted with the accessibility portion at the bottom, but I left some comments to try to connect my thoughts.
packages/tabs/tab.md
Outdated
slot="icon" | ||
label="Checking your work" | ||
aria-label="Tab w/ checkmark" |
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.
I'd have to check with Nikki again, but would we want the label
and aria-label
to be the same, that way screen reader users get the same experience & information?
When I tested this in Safari, VoiceOver also announces: "Tab w slash checkmark" instead of what this was probably going for "Tab with checkmark."
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.
Or maybe the aria-label
replaces label
on sp-tab
?
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.
Now that I think of it, it makes sense to have only the aria-label
exist for icon only situations and it should be on sp-tab
packages/tabs/tab.md
Outdated
yarn add @spectrum-web-components/tabs | ||
``` | ||
|
||
Import the side effectful registration of `<sp-tab>` via: | ||
|
||
``` | ||
```ts |
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.
```ts | |
```js |
packages/tabs/tab.md
Outdated
import '@spectrum-web-components/tabs/sp-tab.js'; | ||
``` | ||
|
||
When looking to leverage the `Tab` base class as a type and/or for extension purposes, do so via: | ||
|
||
```ts |
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.
```ts | |
```js |
packages/tabs/tab.md
Outdated
```html | ||
<sp-tab value="label" label="Label"></sp-tab> | ||
``` |
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.
can you also surface the information whether users need to add both the attributes or not to display a label?
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.
Do you mean both the value
and label
attributes?
I added a line about what the difference was, if that helps.
And then I also updated some of the Accessibility best practices below to be a bit more explicit, it looks like you can use the label
attribute or put the text in the slot content.
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.
nit: If you are not wrapping under sp-tabs
voiceover or keybaord navigation will not work here.
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.
See my suggestion above
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.
Nice work on this! My comments were all addressed from the other day.
I did leave one more comment on the aria-label
and label
conversation we were having. I went back and read Nikki's comment about needing label
on the sp-icon
element, so I'd would need clarity from her on the correct usage of label AND aria-label, so I tagged her just in case.
I'm going to approve so that if it's already good to go in her eyes, y'all can merge iiiiiiit. 👍
packages/tabs/tab.md
Outdated
attribute to define their alignment | ||
</sp-tab-panel> | ||
<sp-tab value="complete" aria-label="Tab with checkmark"> | ||
<sp-icon-checkmark slot="icon"></sp-icon-checkmark> |
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.
I would double check with @nikkimk once more on the aria-label
and label
attributes! From her first comment, it sounded like we still need the label="Checking your work"
, so we should determine where the aria-label
needs to go, and if it should read the same as the label (to me, this sounds like alt text still instead of providing the same info that a label might provide).
packages/tabs/tab.md
Outdated
<sp-icon-checkmark | ||
slot="icon" | ||
label="Checking your work" | ||
></sp-icon-checkmark> |
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.
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.
This will not be picked up by screen-readers. You would need to wrap it under sp-tabs
which manages the focus and tab stops for all children.
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.
@rajdeep is correct. We need to make sure we shoe the tab wrapped in a tabs component.
As part of the documentation standards, "The example code must show the component with enough context to demonstrate how to use it with other elements in an accessible way. See how the examples in packages/help-text/README.md show the component used with field elements."
So even though we are documenting a tab, our examples should still show how to use that tab as part of tabs. This serves many purposes:
- It ensures that our documentation pages are accessible.
- It shows our consumers how to use the tab with tabs in an accessbile way.
- It allows the accessibility team to use our documentation to audit our components as we intend them to work.
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.
Few things to consider.
- Always wrap tabs in
<sp-tabs>
for proper focus management. There are quite a few instances where we are only addingsp-tab
which will not focus. - Use
label
attribute when you want visibletext + icon
- Use
aria-label
attribute when you wanticon-only
tabs - Don't add
aria-label
to the icons - let the tab's label/aria-label handle the accessible name
packages/tabs/tab.md
Outdated
```html | ||
<sp-tab value="label" label="Label"></sp-tab> | ||
``` |
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.
nit: If you are not wrapping under sp-tabs
voiceover or keybaord navigation will not work here.
packages/tabs/tab.md
Outdated
<sp-icon-checkmark | ||
slot="icon" | ||
label="Checking your work" | ||
></sp-icon-checkmark> |
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.
This will not be picked up by screen-readers. You would need to wrap it under sp-tabs
which manages the focus and tab stops for all children.
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.
Thanks for picking this up. I've added some additional suggestions and feedback in the comments.
packages/tabs/tab.md
Outdated
<sp-icon-checkmark | ||
slot="icon" | ||
label="Checking your work" | ||
></sp-icon-checkmark> |
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.
@rajdeep is correct. We need to make sure we shoe the tab wrapped in a tabs component.
As part of the documentation standards, "The example code must show the component with enough context to demonstrate how to use it with other elements in an accessible way. See how the examples in packages/help-text/README.md show the component used with field elements."
So even though we are documenting a tab, our examples should still show how to use that tab as part of tabs. This serves many purposes:
- It ensures that our documentation pages are accessible.
- It shows our consumers how to use the tab with tabs in an accessbile way.
- It allows the accessibility team to use our documentation to audit our components as we intend them to work.
packages/tabs/tab.md
Outdated
```html | ||
<sp-tab value="label" label="Label"></sp-tab> | ||
``` |
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.
See my suggestion above
packages/tabs/tab.md
Outdated
```html | ||
<sp-tabs selected="1" direction="vertical"> | ||
<sp-tabs selected="2"> | ||
<sp-tab label="Tab 1" value="1"></sp-tab> | ||
<sp-tab value="2">Tab 2</sp-tab> | ||
<sp-tab label="Tab 3" value="3"> | ||
<sp-icon-checkmark slot="icon"></sp-icon-checkmark> | ||
</sp-tab> | ||
<sp-tab vertical value="4"> | ||
Tab 4 | ||
<sp-icon-checkmark slot="icon"></sp-icon-checkmark> | ||
</sp-tab> | ||
<sp-tab-panel value="1"> | ||
Content for Tab 1 which uses an attribute for its content delivery | ||
</sp-tab-panel> | ||
<sp-tab-panel value="2"> | ||
Content for Tab 2 which uses its text content directly | ||
</sp-tab-panel> | ||
<sp-tab-panel value="3"> | ||
Content for Tab 3 which uses an attribute with a | ||
<code>[slot="icon"]</code> | ||
child | ||
</sp-tab-panel> | ||
<sp-tab-panel value="4"> | ||
Content for Tab 4 which uses both its text content and a | ||
<code>[slot="icon"]</code> | ||
child displayed using the | ||
<code>[vertical]</code> | ||
attribute to define their alignment | ||
</sp-tab-panel> | ||
<sp-tab label="Tab 2" value="2"></sp-tab> | ||
<sp-tab label="Tab 3" value="3"></sp-tab> | ||
</sp-tabs> | ||
``` |
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.
Since we can't show focused without stealing keyboard focus, we could probably remove the example here.
Co-authored-by: Nikki Massaro <[email protected]>
|
||
An `<sp-tab>` element surfaces a `label` attribute to serve as its default text content when none is available in the DOM. An icon may be assigned to the element via the `icon` slot; e.g. `<sp-tab><svg slot="icon" aria-label="Tab w/ Icon">...</svg></sp-tab>`. Associate an `<sp-tab>` element with the `<sp-tab-panel>` that represents its content with the `value` attribute. | ||
An `<sp-tab>` element surfaces a `label` attribute to serve as its default text content when none is available in the DOM. An icon may be assigned to the element via the `icon` slot; e.g. `<sp-tab><svg slot="icon" label="Tab with icon">...</svg></sp-tab>`. Associate an `<sp-tab>` element with the `<sp-tab-panel>` that represents its content with the `value` attribute. |
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.
Correct me if I'm wrong, my understanding of how icon works from checking the code and the documentation is that if the label attribute is set, it sets aria-label on for us? I made a few small updates to the documentation to reflect this (changing instances of aria-label
to label
), but if that's wrong, please let me know, happy to revert.
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 default slot and the label
attribute both can set the label internally with a <label>
element.
|
||
#### Icon only | ||
|
||
For tabs that have an icon and no visible label, the icon should have a `label` attribute in order to set the `aria-label` of the icon. Icons should not be used just as decoration. If the tab item does not have a visible label, it must still have a tooltip to disclose the label. |
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.
I see this comment about needing a tooltip and the previous comments about wanting to provide "enough context to demonstrate how to use it with other elements in an accessible way" and it feels like tooltip could be part of that. Thoughts? Should I be implementing the tooltip here?
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.
We could provide an example here that uses tooltip and a label
attribute but we should also make very clear that a tooltip is no substitute for a label.
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.
Does tabs support a tooltip? I did look into this a couple of times and wasn't able to get a tooltip rendered here.
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.
Luggage gets tagged meticulously (LGTM)
|
||
An `<sp-tab>` element surfaces a `label` attribute to serve as its default text content when none is available in the DOM. An icon may be assigned to the element via the `icon` slot; e.g. `<sp-tab><svg slot="icon" aria-label="Tab w/ Icon">...</svg></sp-tab>`. Associate an `<sp-tab>` element with the `<sp-tab-panel>` that represents its content with the `value` attribute. | ||
An `<sp-tab>` element surfaces a `label` attribute to serve as its default text content when none is available in the DOM. An icon may be assigned to the element via the `icon` slot; e.g. `<sp-tab><svg slot="icon" label="Tab with icon">...</svg></sp-tab>`. Associate an `<sp-tab>` element with the `<sp-tab-panel>` that represents its content with the `value` attribute. |
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 default slot and the label
attribute both can set the label internally with a <label>
element.
|
||
#### Icon only | ||
|
||
For tabs that have an icon and no visible label, the icon should have a `label` attribute in order to set the `aria-label` of the icon. Icons should not be used just as decoration. If the tab item does not have a visible label, it must still have a tooltip to disclose the label. |
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.
We could provide an example here that uses tooltip and a label
attribute but we should also make very clear that a tooltip is no substitute for a label.
Description
Ensure the full API is documented, including each property, slot, method, event, CSS property, and tokens in the component and along with accessibility concerns and/or decisions, linking to accessibility team documentation where applicable for the tab component.
Related issue(s)
Author's checklist
Reviewer's checklist
patch
,minor
, ormajor
features