Skip to content

Comments

Feat/add aria labels#2871

Closed
Abhishek-Sonje wants to merge 2 commits intoOWASP:mainfrom
Abhishek-Sonje:feat/add-aria-labels
Closed

Feat/add aria labels#2871
Abhishek-Sonje wants to merge 2 commits intoOWASP:mainfrom
Abhishek-Sonje:feat/add-aria-labels

Conversation

@Abhishek-Sonje
Copy link

Proposed Change

Resolves #2628

This PR enhances accessibility across several interactive components by adding appropriate ARIA labels, roles, and descriptive attributes. These improvements strengthen screen reader support and keyboard navigation while preserving the existing UI and behavior.

Summary of Updates

1. NavDropdown

  • Added aria-label to describe the dropdown trigger
  • Added aria-expanded and aria-haspopup="menu" for menu state and semantics
  • Added aria-controls to associate trigger and menu
  • Added role="menu" and role="menuitem" for proper menu structure
  • Added aria-current="page" for active navigation items
  • Marked decorative icons with aria-hidden="true"

2. Search

  • Added role="search" for a search landmark
  • Updated input to type="search"
  • Added meaningful aria-label for the input
  • Linked input to clear button using aria-describedby
  • Added aria-label="Clear search" to the clear action
  • Applied aria-hidden="true" to decorative icons

3. Pagination

  • Replaced wrapper div with semantic <nav> and added aria-label="Pagination"
  • Improved button labels to give clearer state information
  • Preserved correct use of aria-current="page"
  • Marked decorative ellipses with aria-hidden="true"

4. MetricsPDFButton

  • Replaced non-semantic wrapper with a proper <button> for full keyboard accessibility
  • Added aria-label="Download metrics as PDF"
  • Marked decorative icon with aria-hidden="true"
  • Moved event handlers and styling to the button

5. ScrollToTop

  • Expanded aria-label to be more descriptive
  • Added dynamic aria-hidden and tabIndex based on visibility
  • Marked decorative arrow with aria-hidden="true"

Testing Performed

  • Verified all components render correctly in the UI
  • Confirmed expected keyboard behavior (Tab navigation, Enter/Space activation)
  • Ensured no regressions in styling or interaction
  • Verified correct screen-reader output for updated elements

Checklist

  • I have read and followed the contributing guidelines
  • I have run make check-test locally and confirmed that all tests pass
  • I used AI for code assistance, documentation, or tests in this PR

Copilot AI review requested due to automatic review settings December 11, 2025 15:24
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 11, 2025

Caution

Review failed

The pull request is closed.

Summary by CodeRabbit

  • Improvements
    • Enhanced keyboard navigation and screen reader support across navigation menus, pagination controls, search functionality, and interactive buttons throughout the app.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

This PR enhances accessibility across five frontend components by adding ARIA attributes, semantic HTML elements, and improved labeling. Changes include adding aria-labels, roles, aria-hidden attributes, and replacing generic div elements with semantic containers (nav element) in Pagination.

Changes

Cohort / File(s) Change Summary
Accessibility Enhancements Across Components
frontend/src/components/MetricsPDFButton.tsx, frontend/src/components/NavDropDown.tsx, frontend/src/components/Pagination.tsx, frontend/src/components/ScrollToTop.tsx, frontend/src/components/Search.tsx
Added ARIA labels, roles, and visibility attributes (aria-label, role, aria-hidden, aria-describedby, aria-current) to improve screen reader support and semantic markup. Updated Pagination from div to nav element. Wrapped icons with aria-hidden="true" and added tabIndex management to ScrollToTop component.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Homogeneous pattern of ARIA attribute additions across multiple files with no logic changes
  • Verify correct ARIA attribute implementation and semantic HTML usage (especially nav element in Pagination and role="menu" in NavDropDown)
  • Confirm aria-hidden, aria-label, and aria-current values are semantically correct for each component's context

Possibly related issues

Possibly related PRs

Suggested labels

frontend

Suggested reviewers

  • arkid15r
  • kasya
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bfef4da and 467b500.

📒 Files selected for processing (5)
  • frontend/src/components/MetricsPDFButton.tsx (1 hunks)
  • frontend/src/components/NavDropDown.tsx (2 hunks)
  • frontend/src/components/Pagination.tsx (3 hunks)
  • frontend/src/components/ScrollToTop.tsx (1 hunks)
  • frontend/src/components/Search.tsx (1 hunks)

Tip

✨ Issue Enrichment is now available for GitHub issues!

CodeRabbit can now help you manage issues more effectively:

  • Duplicate Detection — Identify similar or duplicate issues
  • Related Issues & PRs — Find relevant issues and PR's from your repository
  • Suggested Assignees — Find the best person to work on the issue
  • Implementation Planning — Generate detailed coding plans for engineers and agents
Disable automatic issue enrichment

To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

issue_enrichment:
  auto_enrich:
    enabled: false

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

The linked issue must be assigned to the PR author.

@sonarqubecloud
Copy link

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances accessibility across five key components by adding ARIA labels, roles, and semantic HTML improvements to better support screen readers and keyboard navigation.

Key Changes:

  • Added semantic ARIA attributes (labels, roles, states) to interactive components
  • Marked decorative icons as aria-hidden="true" throughout
  • Replaced non-semantic elements with proper semantic HTML (div → nav, icon → button)

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
Search.tsx Added search role, ARIA labels, and describedby relationship for clear button
ScrollToTop.tsx Enhanced button label and added dynamic aria-hidden/tabIndex based on visibility
Pagination.tsx Converted wrapper to semantic nav element with pagination label
NavDropDown.tsx Added menu semantics with aria-label, role="menu", and aria-current
MetricsPDFButton.tsx Replaced icon-only element with proper button element for keyboard accessibility

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

</button>
{isOpen && (
<div
role="menu"
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The menu items inside the role="menu" container should have role="menuitem" to properly implement the ARIA menu pattern. Without this, screen readers won't correctly identify these as menu items.

Copilot uses AI. Check for mistakes.
/>
<input
ref={inputRef}
type="text"
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The input type should be "search" for semantic HTML, not "text". The HTML specification defines the search input type which provides better semantics for assistive technologies.

Suggested change
type="text"
type="search"

Copilot uses AI. Check for mistakes.
<input
ref={inputRef}
type="text"
aria-label="search"
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The aria-label should start with a capital letter and be more descriptive to match the standard pattern. Consider using "Search" instead of "search" for consistency with other ARIA labels in the codebase.

Suggested change
aria-label="search"
aria-label="Search"

Copilot uses AI. Check for mistakes.
<span
className="flex h-10 w-10 items-center justify-center text-gray-600 dark:text-gray-400"
role="presentation"
aria-label="More pages"
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The ellipsis span has an aria-label but the icon inside is marked aria-hidden="true". This creates a conflict where screen readers will announce "More pages" but the visual content is hidden from assistive technology. Since the ellipsis is purely decorative and doesn't provide navigation, the entire span should be marked with aria-hidden="true" instead of having an aria-label.

Suggested change
aria-label="More pages"
aria-hidden="true"

Copilot uses AI. Check for mistakes.
onClick={() => setIsOpen((prev) => !prev)}
aria-label={`${link.text} menu`}
aria-expanded={isOpen}
aria-haspopup="true"
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The aria-haspopup value should be "menu" to match the role="menu" on the dropdown container. Currently it's set to "true" which is equivalent to "menu", but using the explicit string value improves clarity and follows ARIA best practices.

Suggested change
aria-haspopup="true"
aria-haspopup="menu"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Good First Issues: 10 Beginner-Friendly Tasks for Backend & Frontend

1 participant