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

[Issue #1885]: fix heading level a11y issue #1923

Merged
merged 5 commits into from
May 6, 2024

Conversation

rylew1
Copy link
Contributor

@rylew1 rylew1 commented May 5, 2024

Summary

Fixes #1885

Time to review: 2 min

Changes proposed

  • Update a couple h4 references to h2 to follow heading level order a11y bug from Lighthouse

Context for reviewers

Lighthouse recommended this article about setting heading levels : https://dequeuniversity.com/rules/axe/4.8/heading-order

Opportunity status becomes larger in the new, but the accordion filter aren't really impacted by the heading level (even though they changed from h4 to h2):

image

Copy link

github-actions bot commented May 5, 2024

Coverage report for ./frontend

St.
Category Percentage Covered / Total
🟢 Statements 83.89% 854/1018
🟡 Branches 64.9% 220/339
🟡 Functions 75.34% 165/219
🟢 Lines 83.89% 797/950

Test suite run success

166 tests passing in 55 suites.

Report generated by 🧪jest coverage report action from c44f8d0

acouch
acouch previously approved these changes May 6, 2024
Copy link
Collaborator

@acouch acouch left a comment

Choose a reason for hiding this comment

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

Great to get these in so quick, thanks.

@@ -68,7 +68,7 @@ const SearchOpportunityStatus: React.FC<SearchOpportunityStatusProps> = ({

return (
<>
<h4 className="margin-bottom-1">Opportunity status</h4>
<h2 className="margin-bottom-1">Opportunity status</h2>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this make the heading larger? If so, you can apply utility classes so the h4 is h2-sized

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andycochran - this did become slightly larger to h2 size - are you suggesting using a div with a utility class that makes it h2 sized? We can't have the h4 tag anymore if we want to avoid the a11y flagged error

Copy link
Collaborator

Choose a reason for hiding this comment

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

Use the h2 (not a div) with font size utility classes to make it look like an h4

Copy link
Collaborator

@andycochran andycochran May 6, 2024

Choose a reason for hiding this comment

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

Hmm. Brainstorming here… 

We could use the same <h2 class="usa-accordion__heading"> so it matches the accordion headings. But that might be a hacky.

.usa-accordion__heading uses:

@include typeset($theme-accordion-font-family, $theme-body-font-size, 1);

…so we'd need to apply utility classes to make it match.

I think just <h2 class="margin-bottom-1 font-sans-md"> will do 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.

font-sans-xs is what was closest to an h4

@@ -116,7 +116,7 @@ export function SearchFilterAccordion({
content: getAccordionContent(),
expanded: false,
id: "funding-instrument-filter",
headingLevel: "h4",
headingLevel: "h2",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This did not increase the size surprisingly - there's some other css that overrides this I think - I didn't investigate further since it just works here

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh! Yeah, this component lets you use whatever heading level you want, but styles them all the same (as consistently-sized accordion headings)

@rylew1 rylew1 merged commit 58dd9ec into main May 6, 2024
10 checks passed
@rylew1 rylew1 deleted the rylew/1885-heading-elements-bug branch May 6, 2024 18:46
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.

[Task]: Bug: Heading Elements are not in a sequentially-descending order
3 participants