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

feat(Row): improve VoiceOver compatibility #1079

Merged
merged 6 commits into from
Apr 29, 2024
Merged

Conversation

atabel
Copy link
Contributor

@atabel atabel commented Apr 11, 2024

Fixes:
WEB-1724
WEB-1740

The main issue that was causing the bugs is that Safari reads links with multiple lines like different links. The workaround for this is:

  • Add an aria-label to the <a> element
  • Add an aria-hidden to the <a> children
  • The aria-label of the <a> should be computed with the content of the row, in this case we are concatenating [title, headline, subtitle, description, extra] props to create the aria-label. The problem is that some of these props aren't simple strings but any ReactNode, so we need to extract the inner text of the html elements on runtime to compute the aria-label for the <a>

Other changes in the PR:

  • Fix some cases where the aria-label was not being set properly in rows with controls (checkbox/radio/switch)
  • Change the dom order of headline to make screen readers read it after title

Still pending:

  • Review badge a11y
  • Review how should screen reader read details part. When the row is a link/button it is read as part of the row as expected. But when we use some control (switch/checkbox/radio) the details part is not read because it's outside the div referenced by aria-labeledby. Including details in the same div used for headline, title, description, etc would require a big refactor of this component layout

Copy link

github-actions bot commented Apr 11, 2024

Size stats

master this branch diff
Total JS 10.6 MB 10.6 MB +2 kB
JS without icons 1.92 MB 1.92 MB +2 kB
Lib overhead 51.4 kB 51.4 kB 0 B
Lib overhead (gzip) 13.9 kB 13.9 kB 0 B

Copy link

github-actions bot commented Apr 11, 2024

Accessibility report
✔️ No issues found

ℹ️ You can run this locally by executing yarn audit-accessibility.

Copy link

github-actions bot commented Apr 11, 2024

Deploy preview for mistica-web ready!

✅ Preview
https://mistica-ij044njit-flows-projects-65bb050e.vercel.app

Built with commit d67f944.
This pull request is being automatically deployed with vercel-action

src/list.tsx Outdated
} = props;

// iOS voiceover reads links with multiple lines as separate links. By setting aria-label and marking content as aria-hidden, we can make it read the whole row as one link.
const iosVoiceOverLabelForLink = [title, subtitle, description, detail].filter(Boolean).join(' ');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

caveat: headline is not read because it isn't included here. The problem is that headline prop is a React.Node, so I can't extract the text

@@ -45,7 +45,7 @@ test('Sheet', async () => {

await userEvent.click(closeButton);
await waitForElementToBeRemoved(sheet);
}, 20000);
}, 30000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's hope it doesn't fail again :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤞

src/list.tsx Outdated Show resolved Hide resolved
@atabel atabel added this pull request to the merge queue Apr 29, 2024
Merged via the queue into master with commit 02f43d7 Apr 29, 2024
11 checks passed
@atabel atabel deleted the atoledano-screen-reader branch April 29, 2024 11:49
tuentisre pushed a commit that referenced this pull request May 6, 2024
# [15.4.0](v15.3.0...v15.4.0) (2024-05-06)

### Bug Fixes

* **AdvancedDataCard:** footer extra space ([#1102](#1102)) ([78e0e80](78e0e80))
* **Chip:** expand chips when inside a grid ([#1108](#1108)) ([32810ee](32810ee))
* **Dialog:** hide optional elements if not provided ([#1093](#1093)) ([1134b4a](1134b4a))
* **Hero:** add bottom padding inside slideshow only when it has bullets ([#1106](#1106)) ([9be0e88](9be0e88))
* **Hero:** use background instead of backgroundColor to support gradients ([#1091](#1091)) ([f4ba119](f4ba119))
* **PreviewTools:** update non working animation for floating case ([#1095](#1095)) ([dfccad5](dfccad5))
* **RowBlock:** set description text alignment to the right ([#1092](#1092)) ([9494d02](9494d02))
* **RowList:** update logic to render last divider ([#1110](#1110)) ([8db09d7](8db09d7))
* **Snackbar:** Desktop position ([#1096](#1096)) ([346f446](346f446))
* **Text:** make vivinho char replacement for screen readers work when Text have multiple children ([#1090](#1090)) ([e5c239c](e5c239c))
* **Video:** avoid duplicated state update in Video's state machine ([#1107](#1107)) ([8ae2ea0](8ae2ea0))

### Features

* **Accordion, Cards, Carousel, Feedback, Sheet, Slider:** replace Array with ReadonlyArray in props ([#1098](#1098)) ([22ee93a](22ee93a))
* **ButtonLink:** change chevron icon in Vivo-new skin ([#1103](#1103)) ([caedc61](caedc61))
* **FixedFooter:** Gradient background support ([#1073](#1073)) ([a7d4bd8](a7d4bd8))
* **Icons:** New routine and ethernet icons ([#1083](#1083)) ([edd7173](edd7173))
* **Image:** add srcSet ([#1109](#1109)) ([fa63884](fa63884))
* **o2-new:** dark mode improvements ([#1105](#1105)) ([d92e404](d92e404))
* **PosterCard:** improve accessibility ([#1087](#1087)) ([c56e177](c56e177))
* **Row:** improve VoiceOver compatibility ([#1079](#1079)) ([02f43d7](02f43d7))
* **Theme:** expose `colorValues` in theme ([#1104](#1104)) ([63c644e](63c644e))
@tuentisre
Copy link
Collaborator

🎉 This PR is included in version 15.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants