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

Make buttons to vote more accessible #4776

Merged
merged 11 commits into from
Feb 23, 2022
Merged

Make buttons to vote more accessible #4776

merged 11 commits into from
Feb 23, 2022

Conversation

javierm
Copy link
Member

@javierm javierm commented Feb 9, 2022

References

Objectives

  • Use buttons instead of links to vote on processes so it's easier for people using screen readers
  • Add an ARIA label to these buttons so people using screen readers have more context about what they're about to vote
  • Move the percentage of agree/disagree votes out of the buttons so the text of the buttons is more clear
  • Fix alignment of the agree/disagree buttons on medium-sized screens
  • Avoid keyboard focus on buttons to vote during the final voting in participatory budgets when people can't vote
  • Make the styles of the buttons to vote legislation annotation comments consistent with the rest of the application

Visual Changes

Most of the changes in this pull request aren't visual; here are some which are indeed visual.

Before these changes

Debates index:

On medium-sized screens, the buttons to agree and disagree are not vertically aligned

Legislation annotation comments:

The colors of the buttons to agree and disagree with legislation annotations aren't consistent with the ones in other sections

After these changes

Debates index:

On medium-sized screens, the buttons to agree and disagree are vertically aligned

Legislation annotation comments:

The colors of the buttons to agree and disagree with legislation annotations are consistent with the ones in other sections

@javierm javierm self-assigned this Feb 9, 2022
@javierm javierm changed the title Improve accessibility of the buttons to vote Make buttons to vote more accessible Feb 9, 2022
@javierm javierm force-pushed the vote_accessibility branch 4 times, most recently from 3559e93 to 2e3db9a Compare February 10, 2022 17:58
This way blind screen reader users will know which proposal they're
supporting. In a list of proposals, context might not be clear when a
link saying "Support" or "Support this proposal" is announced, but a
link saying "Support Create a monthly transport ticket" is less
ambiguous.

Just like we did with investments in commit de436e3, we're keeping the
title attribute because when visiting a proposal page, the connection
between the "Support" link and the proposal is not as clear as it is in
the proposals index page, so it might not be clear what you're
supporting.
Note we're using the `budgets.investments.investment.add_label` and
`budgets.ballots.show.remove_label` internationalization keys so they're
consistent with the `budgets.investments.investment.add` and
`budgets.ballots.show.remove` keys which were already present. We aren't
unifying these keys in order to keep existing translations.
As mentioned in commits 5311daa and bb958da, using links combined
with JavaScript to generate POST requests to the server has a few
issues.
As mentioned in commits 5311daa and bb958da, using links combined
with JavaScript to generate POST requests to the server has a few
issues.
Having buttons (previously links) with the text "I agree 75%" is
confusing; people might believe they're saying they only partially agree
with the content. Besides, the results percentages is a different piece
of information which shouldn't be related to whether one person
agrees/disagrees with the content.

This problem might be solved for people using screen readers since we
added the aria-label attribute. However, for sighted keyboard users, the
percentage was being outlined on focus as part of the button, which
might be confusing.
This way we can simplify the code in the views a little bit.
Using the `flex-with-gap` mixin we avoid the left margin in the second
element when the screen space isn't wide enough to show both buttons.

Setting the margins with CSS also allows as to simplify the view and
makes it easier to customize styles.
As mentioned in commits 5311daa and bb958da, using links combined
with JavaScript to generate POST requests to the server has a few
issues.

We're also improving the keyboard access. Previously, the links were
focusable and clickable with the keyboard. Now we're disabling the
buttons when voting isn't allowed.

Since these elements can no longer be focused, we're adding an element
with `tabindex="0"` so the "participation not allowed" message is shown,
like we do in most places.

Note we're slightly changing one test because now when hovering over the
button on Chrome, the "participation not allowed" text isn't shown; it's
only shown when hovering on the parts of the `div.ballot` element
outside the button. Since we're already rewriting the behavior of the
"participation not allowed" text in a different pull request, we aren't
going to fix this behavior.
As mentioned in commits 5311daa and bb958da, using links combined
with JavaScript to generate POST requests to the server has a few
issues.
Note we're using the in-favor HTML class instead of the in_favor class
so we're consistent with our conventions for HTML classes and because we
use the in-favor class in similar places.

Also note the styles of the legislation process annotations/comments
buttons is now similar to the styles in the other sections. Previously,
the colors didn't have enough contrast and there was a very strange
margin between the "thumbs up" icon and the number of people agreeing
(that margin wasn't present between the "thumbs down" icon and the
number of people disagreeing).
Base automatically changed from refactor_votes to master February 23, 2022 16:43
@javierm javierm merged commit b9a0b34 into master Feb 23, 2022
@javierm javierm deleted the vote_accessibility branch February 23, 2022 16:45
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.

2 participants