Skip to content

Commit

Permalink
fix: add role img to app header picker network (#23842)
Browse files Browse the repository at this point in the history
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

To improve the accessibility of our ~Avatar components~, especially when
a screen reader is used, we propose adding the role="img" attribute to
these components. This enhancement aims to prevent screen readers from
reading out the fallback letter, providing a more meaningful and
contextually appropriate description. For instance, when tabbing through
networks in the extension, the screen reader should announce "S,
Sepolia" instead of just "S". This change will ensure our UI is more
accessible and user-friendly for individuals relying on screen readers.

Upon further investigation with @georgewrmarshall, we came to the
conclusion that it is best suited for the issue to be applied to the
`app header network picker`.

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/23832?quickstart=1)

## **Related issues**

Fixes: #23251 

## **Manual testing steps**

1. Turn on your computers screen reader (mac: CMD + F5)
2. Run local build of extension 
3. Tab to a component that uses an avatar component (e.g. see screenshot
for example component)

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**


https://github.com/MetaMask/metamask-extension/assets/8112138/ec6ab28f-8fbf-4cd2-b0ea-787f82d7bcae

<!-- [screenshots/recordings] -->

### **After**



https://github.com/MetaMask/metamask-extension/assets/26469696/bef063ff-41d7-4738-98b3-625013861d75




<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
garrettbear authored Apr 4, 2024
1 parent 3442194 commit 58f380c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,14 @@ exports[`App Header should match snapshot 1`] = `
>
<div>
<button
aria-label="Network Menu Chain 5"
class="mm-box mm-picker-network multichain-app-header__contents__network-picker mm-box--margin-2 mm-box--padding-right-4 mm-box--padding-left-2 mm-box--display-none mm-box--sm:display-flex mm-box--gap-2 mm-box--align-items-center mm-box--background-color-background-alternative mm-box--rounded-pill"
data-testid="network-display"
disabled=""
>
<div
class="mm-box mm-text mm-avatar-base mm-avatar-base--size-xs mm-avatar-network mm-picker-network__avatar-network mm-text--body-xs mm-text--text-transform-uppercase mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-text-default mm-box--background-color-background-alternative mm-box--rounded-full mm-box--border-color-transparent box--border-style-solid box--border-width-1"
role="img"
>
C
</div>
Expand Down
11 changes: 10 additions & 1 deletion ui/components/multichain/app-header/app-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,16 @@ export const AppHeader = ({ location }) => {
<PickerNetwork
avatarNetworkProps={{
backgroundColor: testNetworkBackgroundColor,
role: 'img',
}}
className="multichain-app-header__contents--avatar-network"
ref={menuRef}
as="button"
src={currentNetwork?.rpcPrefs?.imageUrl}
label={currentNetwork?.nickname}
aria-label={t('networkMenu')}
aria-label={`${t('networkMenu')} ${
currentNetwork?.nickname
}`}
labelProps={{
display: Display.None,
}}
Expand All @@ -262,8 +265,12 @@ export const AppHeader = ({ location }) => {
<PickerNetwork
avatarNetworkProps={{
backgroundColor: testNetworkBackgroundColor,
role: 'img',
}}
margin={2}
aria-label={`${t('networkMenu')} ${
currentNetwork?.nickname
}`}
label={currentNetwork?.nickname}
src={currentNetwork?.rpcPrefs?.imageUrl}
onClick={(e) => {
Expand Down Expand Up @@ -482,7 +489,9 @@ export const AppHeader = ({ location }) => {
<PickerNetwork
avatarNetworkProps={{
backgroundColor: testNetworkBackgroundColor,
role: 'img',
}}
aria-label={`${t('networkMenu')} ${currentNetwork?.nickname}`}
label={currentNetwork?.nickname}
src={currentNetwork?.rpcPrefs?.imageUrl}
onClick={(e) => {
Expand Down

0 comments on commit 58f380c

Please sign in to comment.