Skip to content

Use nested react-animated-dataset#1651

Merged
SaptakS merged 7 commits into
developfrom
switch-react-animated-dataset
Jun 21, 2023
Merged

Use nested react-animated-dataset#1651
SaptakS merged 7 commits into
developfrom
switch-react-animated-dataset

Conversation

@dkaoster
Copy link
Copy Markdown
Contributor

@dkaoster dkaoster commented May 16, 2023

Implements the updated nesting feature in freedomofpress/react-animated-dataset#1

Everything appears to work the same, maybe would be a good time to see if this is a better approach for accessibility @SaptakS.

The main goal of doing this is outlined in this issue, as this should allow for better composability and accessibility when using react-animated-dataset, enabling us to do something like:

<AnimatedDataset
  dataset={['Hello World', 'Goodbye World']}
  tag="a"
  attrs={{ href: "#test" }}
  keyFn={t => t}
  disableAnimation
>
  <AnimatedDataset
    tag="text"
    attrs={{ text: t => t }}
    keyFn={t => t}
    disableAnimation
  />
</AnimatedDataset>

dkaoster added 2 commits May 17, 2023 10:23
# Conflicts:
#	client/charts/js/components/TreeMap.jsx
@sssoleileraaa
Copy link
Copy Markdown

To test this, should one just make sure there are no regressions? Or is the plan to do most of the testing once it's merged and before deployment, as mentioned here: freedomofpress/react-animated-dataset#1 (comment)?

I have cycles to help out with testing if needed.

@harrislapiroff
Copy link
Copy Markdown
Contributor

@sssoleileraaa Hm, unfortunately, I think this one might be tricky for you to test because it really depends on an assessment of whether we like the new code APIs @dkaoster has introduced into react-animated-dataset and whether they meet our needs for making more accessible charts. Intimate knowledge of the code base is helpful here. We can keep an eye out for PRs that might be a better introduction if you're excited to get your eyes on the code a bit!

@sssoleileraaa
Copy link
Copy Markdown

Ah, yes, that makes sense @harrislapiroff. Thanks for keeping an eye out - in general, I'm happy to help test new stuff before deployments. :)

@SaptakS
Copy link
Copy Markdown
Contributor

SaptakS commented Jun 6, 2023

@dkaoster though I haven't started looking at it yet, it would be great if you could rebase and resolve the merge conflicts.

# Conflicts:
#	client/charts/js/components/HomepageMainCharts.jsx
#	client/charts/js/components/USMap.jsx
@SaptakS
Copy link
Copy Markdown
Contributor

SaptakS commented Jun 14, 2023

Firstly, I think the nested react-animated-dataset works great. However, some of the ways it has been used here is what I am kind of reviewing.

It does work using keyboard navigation, but the accessibility tree is not very promising in certain cases. I do want to do some more testing using screen reader itself, hence not requesting any immediate changes, but few of the things I noted:

  • The <a> tag in svg doesn't have a proper role. So in the tree, it shows role="nothing", accessible name=null. I am not sure how things will be announced in screenreader, I will test that as well.
    • Solution to this might be to add a role and accessible name attributes
  • In some cases, like in the treemap, the <a> tag actually doesn't wrap the text. The text hence appears separately in the accessibility tree. I think we should try to wrap the text with the tag if possible. That might make the screenreader sound okay even without adding an accessible name (and also makes more sense structurally.

Like I said before, I do think that the nested react-animated-dataset is definitely helpful, though we might need to figure out the exact structuring

Copy link
Copy Markdown
Contributor

@SaptakS SaptakS left a comment

Choose a reason for hiding this comment

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

As I had expected, while tabbing through the different elements in a chart, there is no screenreader feedback at all. It just tells that there is a focus element but no details on it.

What the final HTML should ideally look like is this:
image

Notice the role attribute and aria-labelledBy attributes. I tried adding them in the react-animated-dataset tag and it didn't seem to work, so I am not sure if more work might be needed to be done in the other PR to make it possible to have these attributes. But I think we definitely want to have role="link" whenever we have a link, and have an aria-labelledBy attribute pointing to the element which has the text in it.

Ideally, for better structure, it would be nice to have the elements with the text appear inside the anchor tag if possible.

@dkaoster
Copy link
Copy Markdown
Contributor Author

@SaptakS Just added the role and aria-label in, it is totally configurable and easy to do. I think the point about restructuring so that the text is inside the anchor links might be a little bit more challenging but I'll look into that!

Copy link
Copy Markdown
Contributor

@SaptakS SaptakS left a comment

Choose a reason for hiding this comment

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

This looks really good to me. I am going to approve this. I think some snapshots are failing the tests that need to be fixed?
Also, @harrislapiroff what is the plan with react-animated-dataset changes? Should I merge this as is and then the plan is to open a PR to the upstream repo?

@harrislapiroff
Copy link
Copy Markdown
Contributor

@SaptakS Yes, let's merge as is and then live with the changes for a couple weeks and then, if we're happy with them, we'll put in a PR upstream. (So leave it in blocked for now.)

@SaptakS
Copy link
Copy Markdown
Contributor

SaptakS commented Jun 21, 2023

@harrislapiroff okay. Once @dkaoster updates the tests to fix CI, I will merge it.

@dkaoster
Copy link
Copy Markdown
Contributor Author

whoops! that should do it

@SaptakS SaptakS merged commit 5e7f31c into develop Jun 21, 2023
@SaptakS SaptakS deleted the switch-react-animated-dataset branch June 21, 2023 17:22
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