Skip to content

Conversation

@Westbrook
Copy link
Contributor

Description

Expand the testing suite to rely on await expect(el).to.be.accessible(); more liberally, and correct prior use of this command that omitted the await signifier.

  • swap a lot of .to.equalSnapshot(); tests for this approach as the DOM internal to our components is private API and doesn't need to be guaranteed across functional changes whereas the accessibility of our components does.
  • clean up unused snapshots
  • ensure elements meet even the low level of accessibility that can be confirmed by automation

Motivation and Context

How Has This Been Tested?

  • unit tests in the CI

Screenshots (if appropriate):

Before:
image
After:
image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

<img
src="${this.hero}"
slot="hero"
aria-hidden="true"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is cheating! Currently, Spectrum CSS uses a background image for this, which is very close to the same level of cheating, so I wasn't sure what to do about applying an alt tag here. Should we use aria-hidden? Should we reapply the headline text? Should we surface an additional attribute? Should we move to a background image? I'm not sure the right path for both functionality and accessibility here...

Copy link
Contributor Author

@Westbrook Westbrook Jun 10, 2020

Choose a reason for hiding this comment

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

Alternates...

<sp-dialog-wrapper headline="Text" /> 
...
<img
 src="${this.hero}"
 slot="hero"
 alt="${this.headline}"
/>
<sp-dialog-wrapper hero-label="Text" /> 
...
<img
 src="${this.hero}"
 slot="hero"
 alt="${this.heroLabel}"
/>
<sp-dialog-wrapper /> 
...
<img
 src="${this.hero}"
 slot="hero"
 alt="Hero"
/>

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed offline, the second alternate that leverages the hero-label attribute makes the most sense to me.

Both the headline and hero-label alternatives align with how we're handling the alt tag of shadowDOM images in other components, such as Avatar. I prefer the hero-label implementation, since the headline of the dialogWrapper doesn't always align with the contents of the hero image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated sp-dialog-wrapper to include hero-label attribute which applies to the alt attribute to the <img /> when available. When unavailable, the aria-hidden="true" practice is maintained.

: html``}
</div>
<div class="content">
<div class="content" tabindex="0">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jnurthen would love some additional insight here. This is based on the feedback in https://dequeuniversity.com/rules/axe/3.4/scrollable-region-focusable?application=axeAPI. However, this element won't always be "scrollable" even though it has overflow: auto, due to content size. Do we need to dynamically cover for that? Or, is it OK to make it focusable even when the content doesn't require scroll?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should also have a visible reaction to focusable elements, right? If this makes sense to move forward with, I'll need to submit an issue to Spectrum CSS generally for the absence of such styles. Maybe @lazd would have some thoughts on that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andrewhatran I've thought about this some more, and while it seems sub-optimal to have or not have the tabindex 100% of the time like this, it seems slightly less so to have it 100% of the time AND any updates we make to when it is available in the future would essentially be within the private API scope of the element, so there is no need to block on them now. I've created #723 to track the additional functionality and design application that will likely be needed. Without directly addressing this question now, I think we should be OK moving forward on a more complete review of this PR when you have some time! Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

This totally makes sense to me. If we're planning on updating this component in the future to make the tabindex responsive to the scrollability of the element, then I feel comfortable with moving forward with this workaround 👍

I'll continue with a more thorough/complete review as soon as I have time!

@Westbrook
Copy link
Contributor Author

FYI: CI fails because of an expected change in the screenshot testing. Want to make sure we work through any alterations of the actual code in this PR before I bump the golden image cache.

@Westbrook Westbrook requested a review from andrewhatran June 8, 2020 15:33
@Westbrook Westbrook force-pushed the westbrook/switch branch 2 times, most recently from ed86dc7 to 4fc47a8 Compare June 9, 2020 01:36
this.inputElement.setAttribute(
'aria-checked',
this.checked ? 'true' : 'false'
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jnurthen The testing pointed out that switches with role="switch" require aria-checked where as checkboxes (the base of this component) don't. Does that checkout appropriately on your end?

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense to me.

@Westbrook Westbrook changed the base branch from master to main June 12, 2020 03:07
<sp-actionbar open>
<sp-checkbox indeterminate>228 Selected</sp-checkbox>
<div class="spectrum-ButtonGroup">
<sp-button-group>
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@property()
public hero = '';

@property({ attribute: 'hero-label' })
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@andrewhatran andrewhatran left a comment

Choose a reason for hiding this comment

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

Looks good to me, nice job 🎉

@Westbrook Westbrook merged commit 263bc66 into main Jun 17, 2020
@Westbrook Westbrook deleted the westbrook/switch branch June 17, 2020 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants