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

[ACS] - Add accessibility to snackbar #858

Merged
merged 3 commits into from
Jan 7, 2025
Merged

Conversation

diogoverde
Copy link
Contributor

JIRA Issue

Description 📄

  • Added accessibility to snackbar
  • Add custom aria label to close button

Platforms 📲

  • Web
  • Mobile

Type of change 🔍

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested? 🧪

  • Unit Test
  • Snapshot Test

Checklist: 🔍

  • My code follows the contribution guide of this project Contributing Guide
  • Layout matches design prototype: FIGMA
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Screenshots 📸

[Upload your screenshots here]

Before After

packages/yoga/src/Snackbar/web/Snackbar.jsx Outdated Show resolved Hide resolved
<IconButtonWrapper
role="button"
onClick={onClose}
aria-label={ariaLabelClose}
Copy link
Contributor

Choose a reason for hiding this comment

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

For this element to be considered interactive, it would be necessary to add tabindex="0" and listen for "Enter" or "space" to trigger the onClose, this is done automatically if you change the element's tag to button.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point! changed accordingly

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could change the styled-component tag to simplify.

An element that has the button tag already has the role button implicitly.

-const IconButtonWrapper = styled.div`
+const IconButtonWrapper = styled.button`
              <IconButtonWrapper
-               role="button"
                onClick={onClose}
                aria-label={ariaLabelClose}
-               as="button"
              >

<IconButtonWrapper
role="button"
onClick={onClose}
aria-label={ariaLabelClose}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could change the styled-component tag to simplify.

An element that has the button tag already has the role button implicitly.

-const IconButtonWrapper = styled.div`
+const IconButtonWrapper = styled.button`
              <IconButtonWrapper
-               role="button"
                onClick={onClose}
                aria-label={ariaLabelClose}
-               as="button"
              >

alignItems="center"
mr="small"
role="img"
data-testid="img"

Choose a reason for hiding this comment

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

Instead of using a string directly here, use it via props

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what should be added as a prop, the data-testid?

Choose a reason for hiding this comment

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

Yes, this way we avoid possible problems with testing

color: inherit;
border: none;
padding: 0;
outline: inherit;

Choose a reason for hiding this comment

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

Do these style changes have a visual impact? If so, could you include some screen shots so we can visualize the changes, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it does not, they are added so that it won't affect the visuals. Since it was converted to a button

@alvim-wh alvim-wh merged commit 7674a28 into master Jan 7, 2025
4 checks passed
@alvim-wh alvim-wh deleted the feat/accessibility-snackbar branch January 7, 2025 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants