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

654: Announce Number of Filters & 627: Keep Keyboard Focus on Filter Button #687

Merged
merged 3 commits into from
Jun 10, 2024
Merged

654: Announce Number of Filters & 627: Keep Keyboard Focus on Filter Button #687

merged 3 commits into from
Jun 10, 2024

Conversation

jgrimes86
Copy link
Contributor

This PR addresses issues #654 and #627

For issue 654:
Two screen-reader-only spans have been added to the filter button label so that a screen reader can announce the filter button with the number of filters currently applied. When no filters are applied it announces 'Filter button'. When 2 filters are applied, it announces 'Filter button 2 filters applied'. To allow the screen reader to read the label in that order, the aria-label property was removed and the default 'Button' announcement is overridden by adding aria-roledescription=' '

For issue 627:
The 'if' statement has been removed from the filtuer button's onPress function so that the focus stays on the filter button when filter view is toggled off.

To test:

  • go to the Find Properties page
  • using a screen reader, TAB to the Filter button, which will be announced as 'filter button'
  • hit SPACE or ENTER to enter the filter view
  • select one or more filter categories
  • SHIFT+TAB back to the filter button, which will be announced as 'filter button [#] filters applied current' (Note: the word 'current' included in the announcement is the subject of issue 625)
  • test focus with [screen reader key]+TAB, which will announce 'filter button [#] filters applied focused current'
  • hit SPACE or ENTER to exit filter view
  • test focus again with [screen reader key]+TAB, which will again announce 'filter button [#] filters applied focused current

Note: If one of the active filters is a panel in the 'Get Access' section and you tab back into the filter view, the panel will not appear selected, although though the filter will still be active. This is a bug being addressed by issue 685

Copy link

vercel bot commented Jun 8, 2024

@jgrimes86 is attempting to deploy a commit to the Clean and Green Philly Team on Vercel.

A member of the Team first needs to authorize it.

@jgrimes86
Copy link
Contributor Author

@bacitracin or @marvieqa I think you are the appropriate code approvers to review this PR?

@jgrimes86
Copy link
Contributor Author

I think this PR also addresses issue #626, which appears to be a duplicate if issue #654 (or vice versa)

Issue 626 suggests using <aria-label=" Filter, 3 Filters applied">. I abandoned the existing aria-label before I realized that I could mute the default 'button' announcement by including aria-roledescription=' '.

I could try to revise this PR to use a variable for the aria-label instead of using the screen-reader-only elements that I've added. In hindsight, that seems like better practice, but I'll wait for input from the PR review before I re-work things.

@bacitracin
Copy link
Collaborator

@bacitracin or @marvieqa I think you are the appropriate code approvers to review this PR?

@jgrimes86 Thanks for the heads up. In the future you can feel free to tag me under Reviewers for a11y-related PRs.

@jgrimes86
Copy link
Contributor Author

jgrimes86 commented Jun 9, 2024

@bacitracin I made a commit to this PR to re-add the aria-label and get rid of the screen-reader only components. Looking through previous PRs, I saw that one of them (number 608) had added the aria-label so that the screen reader would correctly announce the button on small screens, so me deleting it re-introduced an issue that was previously fixed.

I figured whatever other changes or corrections are needed, that issue was yet another reason to put the aria-label back so I might as well take care of it now.

@@ -103,20 +103,15 @@ const SearchBarComponent: FC<SidePanelControlBarProps> = ({
)}
<ThemeButton
color="tertiary"
aria-label="Filter"
aria-label={filterCount === 0 ? "Filter Button" : `Filter Button ${filterCount} filters active`}
aria-roledescription=' '
Copy link
Collaborator

@bacitracin bacitracin Jun 9, 2024

Choose a reason for hiding this comment

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

Keeping the semantic meaning of the button is more important than matching the suggested text order, so you can remove this line 'aria-roledescription=' '. Also aria-roledescription should never be an empty string, it should be a semantic role that you apply to divs or other HTML elements that have no existing role.

For the aria-label you usually don't want to include words like "button" or "image." Ideally that will come from the component being coded semantically (a real button element instead of a div for ex). So once you remove that aria-roledescription line, you can also remove "button" from both of the labels.

Copy link
Collaborator

@bacitracin bacitracin Jun 9, 2024

Choose a reason for hiding this comment

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

Here is what it sounds like on VoiceOver/Chrome
no filters selected
Screenshot 2024-06-09 at 6 22 33 PM

2 filters selected
Screenshot 2024-06-09 at 6 22 19 PM

@bacitracin
Copy link
Collaborator

@jgrimes86 Thanks for adding the aria-label back in. I had a small cleanup comment. You don't need the "button" text or the "aria-roledescription." Other than that, looks good! You can tag me again when it's updated and I'll approve/merge.

@jgrimes86
Copy link
Contributor Author

@bacitracin I made those changes. Thank you for the explanations in the code comments.

Copy link
Collaborator

@bacitracin bacitracin left a comment

Choose a reason for hiding this comment

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

👍 Looks good!

@bacitracin bacitracin merged commit 0842406 into CodeForPhilly:staging Jun 10, 2024
1 of 2 checks passed
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.

2 participants