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(store-ui): Fix search-input a11y #1000

Merged
merged 5 commits into from
Oct 21, 2021
Merged

Conversation

israelswf
Copy link
Contributor

@israelswf israelswf commented Oct 20, 2021

What's the purpose of this pull request?

This PR intends to solve accessibility (a11y) issues in the SearchInput component, by adding aria-labels to either the input and button in it. The lack of these a11y improvements is making this base.store PR fails.

How it works?

When screen readers read the content of these aria-labels, they will be capable of giving the correct feedback on what is being focused at the moment (since neither the input has a label element, nor the button has a value in it describing what they are/do).

How to test it?

After importing the StoreInput component you can test it using the following methods:

  • By running the lighthouse report from a base.store deploy
  • By using a screen reader to check the feedbacks from the inserted aria-labels

base.store Deploy Preview

base.store deploy preview

References

@netlify
Copy link

netlify bot commented Oct 20, 2021

✔️ Deploy Preview for storeui ready!

🔨 Explore the source changes: ce17943

🔍 Inspect the deploy log: https://app.netlify.com/sites/storeui/deploys/617172437c8e670007577153

😎 Browse the preview: https://deploy-preview-1000--storeui.netlify.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 20, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit ce17943:

Sandbox Source
Store UI Typescript Configuration

@israelswf israelswf self-assigned this Oct 20, 2021
@israelswf israelswf marked this pull request as ready for review October 20, 2021 14:14
@israelswf israelswf requested a review from a team as a code owner October 20, 2021 14:14
Comment on lines 22 to 28
describe('Accessibility', () => {
it('should have no violations', async () => {
const { getByTestId } = render(<Wrapper />)

expect(await axe(getByTestId('search-input'))).toHaveNoViolations()
})
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you put this test suite inside the Search Input test suite?

/**
* Custom aria-label for input and button.
*/
ariaLabel?: string
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO, i prefer to use aria-label as the HTML does.

Suggested change
ariaLabel?: string
aria-label?: ArriaAttributes['aria-label']

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, could receive aria-labelledby.

/**
* Custom aria-label for input and button.
*/
ariaLabel?: string
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, could receive aria-labelledby.

<Input
ref={valueRef}
aria-label={ariaLabel}
aria-labelledby={ariaLabelledBy}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it necessary to explicitly put aria-labelledby here? I understand aria-label because you added a default value to it, but wouldn't aria-labelledby be added through {...props} anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for bringing that out, @lariciamota, your point makes total sense to me. I've added the aria-labelledby as Brasileiro suggested before, but I haven't reflect much on it. Any considerations about Laricia's point, @igorbrasileiro?

@israelswf israelswf merged commit f052f46 into master Oct 21, 2021
@israelswf israelswf deleted the fix/a11y-search-input branch October 21, 2021 14:15
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