Skip to content

Add accessibility semantics and focus management to Modal component#18

Draft
Copilot wants to merge 4 commits intofeat/personal-sitefrom
copilot/sub-pr-13-yet-again
Draft

Add accessibility semantics and focus management to Modal component#18
Copilot wants to merge 4 commits intofeat/personal-sitefrom
copilot/sub-pr-13-yet-again

Conversation

Copy link
Contributor

Copilot AI commented Feb 12, 2026

The Modal component was missing ARIA attributes and focus management, breaking keyboard and screen reader navigation.

Changes

ARIA semantics:

  • role="dialog", aria-modal="true", aria-labelledby on modal container
  • aria-label on close button, aria-hidden on backdrop
  • tabIndex={-1} for programmatic focus

Focus management:

  • Save/restore focus to trigger element on open/close
  • Focus modal container on open for screen reader context

Focus trap:

  • Tab/Shift+Tab cycles between focusable elements within modal
  • Comprehensive selector handles buttons, links, inputs, contenteditable, media controls
  • Guards for empty focusable lists
// Before: no semantic markup
<div className="...">
  <h3>{title}</h3>
  <button onClick={onClose}>×</button>
</div>

// After: full accessibility
<div
  ref={modalRef}
  role="dialog"
  aria-modal="true"
  aria-labelledby={titleId}
  tabIndex={-1}
>
  <h3 id={titleId}>{title}</h3>
  <button onClick={onClose} aria-label="Close modal">×</button>
</div>

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI mentioned this pull request Feb 12, 2026
@vercel
Copy link

vercel bot commented Feb 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
string-v2 Ready Ready Preview, Comment Feb 12, 2026 4:07pm

Co-authored-by: ghostleek <44336310+ghostleek@users.noreply.github.com>
Copilot AI and others added 2 commits February 12, 2026 16:03
Co-authored-by: ghostleek <44336310+ghostleek@users.noreply.github.com>
…focus restore, handle empty focusable list

Co-authored-by: ghostleek <44336310+ghostleek@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP Address feedback on personal site PR Add accessibility semantics and focus management to Modal component Feb 12, 2026
Copilot AI requested a review from ghostleek February 12, 2026 16:05
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