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

Improve accessibility of React components #1612

Merged
merged 47 commits into from
Aug 24, 2023
Merged

Conversation

ivababukova
Copy link
Contributor

@ivababukova ivababukova commented Jul 17, 2023

Fixes #1467 and Fixes #787

Background

Change List

Checklist

  • Ensure PR works with all demos on the dev.vitessce.io homepage
  • Open (draft) PR's into vitessce-python and vitessce-r if this is a release PR
  • Documentation added or updated

@ivababukova ivababukova changed the title Ivababukova/accessiility Improve accessibility of React components Jul 17, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 17, 2023

Size Change: +7.91 kB (0%)

Total Size: 11.4 MB

Filename Size Change
./packages/main/prod/dist/index-********.js 6.94 MB +7.91 kB (0%)
ℹ️ View Unchanged
Filename Size
./packages/main/prod/dist/deflate-********.js 243 B
./packages/main/prod/dist/hglib-********.js 4.34 MB
./packages/main/prod/dist/index.min.js 687 B
./packages/main/prod/dist/jpeg-********.js 15.3 kB
./packages/main/prod/dist/lerc-********.js 47.2 kB
./packages/main/prod/dist/lzw-********.js 2.1 kB
./packages/main/prod/dist/packbits-********.js 576 B
./packages/main/prod/dist/pako.esm-********.js 68.6 kB
./packages/main/prod/dist/raw-********.js 168 B
./packages/main/prod/dist/webimage-********.js 872 B

compressed-size-action

@github-actions
Copy link
Contributor

github-actions bot commented Jul 18, 2023

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 78.47% 9265 / 11807
🔵 Statements 78.47% 9265 / 11807
🔵 Functions 65.6% 267 / 407
🔵 Branches 79.29% 881 / 1111
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
packages/view-types/scatterplot/src/shared-spatial-scatterplot/ToolMenu.js 72.22% 100% 66.66% 72.22% 105-144
Generated in workflow #3114

packages/view-types/feature-list/src/FeatureListOptions.js Outdated Show resolved Hide resolved
export const channelSliderStyles = makeStyles(theme => ({
valueLabel: {
marginTop: '7px',
'& *': {
Copy link
Member

Choose a reason for hiding this comment

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

Can this selector be more specific?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, done in this commit: ee2c738

packages/view-types/scatterplot/src/ScatterplotOptions.js Outdated Show resolved Hide resolved
return (
<TableRow>
<TableCell className={classes.cameraLabel}>
return use3d && (
Copy link
Member

Choose a reason for hiding this comment

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

Is this change to using rendering vs. the disabled prop related to accessibility?

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 is done for the same reasons as this one: https://github.com/vitessce/vitessce/pull/1612/files#r1266860907 Let me know if I should revert it.

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 read the comments further and I see that both of you are on the opinion that using disabled is better, so I reverted this change in commit e5371cb

packages/view-types/spatial/src/SpatialOptions.js Outdated Show resolved Hide resolved
@keller-mark
Copy link
Member

We should also start using https://react.dev/reference/react/useId

Copy link
Collaborator

@NickAkhmetov NickAkhmetov left a comment

Choose a reason for hiding this comment

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

Thanks for taking on this monumental task!

I have some suggestions after reviewing tooltip and view-types; I will continue my review picking up from the vit-s directory tomorrow.

To sum up my thoughts so far:

  • I agree with @keller-mark re: the use of useId, especially for components which may appear more than once on a page; does the current solution work if there's a second vitessce instance further down the page?
  • I also second preferring to disable controls rather than conditionally render them. Controls popping in and out of existence is detrimental to user experience, especially for users of screen-readers.
  • I think a lot of the places where key is currently in use may be better served with an id instead.
  • Slider accessibility may be further enhanced in cases where there are multiple thumbs on one slider by having dynamic aria labels for each thumb.

packages/tooltip/src/Tooltip.js Outdated Show resolved Hide resolved
packages/view-types/feature-list/src/FeatureListOptions.js Outdated Show resolved Hide resolved
packages/view-types/heatmap/src/HeatmapOptions.js Outdated Show resolved Hide resolved
packages/view-types/heatmap/src/HeatmapOptions.js Outdated Show resolved Hide resolved
packages/view-types/heatmap/src/HeatmapOptions.js Outdated Show resolved Hide resolved
packages/view-types/scatterplot/src/ScatterplotOptions.js Outdated Show resolved Hide resolved
packages/view-types/scatterplot/src/ScatterplotOptions.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@NickAkhmetov NickAkhmetov left a comment

Choose a reason for hiding this comment

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

After reviewing the rest of the changes, the feedback so far should cover just about everything I saw, i.e.:

  • Opt for disabled over conditional rendering
  • Use id instead of key in most places where a key has been added
  • Consider useId for anything that can appear more than once on a page

Copy link
Collaborator

@NickAkhmetov NickAkhmetov left a comment

Choose a reason for hiding this comment

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

Great job, thank you for making those corrections!

I have a few remaining concerns:

  • I'm not sure that using ['string-1', 'string-2'].join('-') is the best for clarity in defining ID's; could we use template strings instead?
  • ARIA labels should be brief (same as any input label, ideally); if there's a full sentence/if a period is needed, using aria-description is a good way to provide any extra context while keeping the label itself short and to the point.

@ivababukova
Copy link
Contributor Author

ivababukova commented Aug 17, 2023

Thanks for the review @NickAkhmetov. I have now addressed all your comments. In terms of the concerns you outlined:

  • I'm not sure that using ['string-1', 'string-2'].join('-') is the best for clarity in defining ID's; could we use template strings instead?

Yes, you are totally right, I went with ['string-1', 'string-2'].join('-') purely out of habit. The code is now corrected to use template strings instead.

  • ARIA labels should be brief (same as any input label, ideally); if there's a full sentence/if a period is needed, using aria-description is a good way to provide any extra context while keeping the label itself short and to the point.

Good point. I have changed the aria-labels, removing the . and making the longer ones briefer, where sensible.

Could you take a look at this PR again and let me know if there is anything else that should be fixed?

Copy link
Collaborator

@NickAkhmetov NickAkhmetov left a comment

Choose a reason for hiding this comment

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

Great work, thank you for making those revisions! I have no further concerns; if @keller-mark has no additional comments, this should be good to merge in my opinion! 👏

ivababukova and others added 3 commits August 21, 2023 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants