Make ModalDialog accessible by default

Open
#1,927 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
html, java, javascript

Research direction

Start from the ModalDialog source in wicket-extensions, where the dialog element is rendered as a <div> and trapFocus()/closeOnEscape() are opt-in, then read the "Dialogs" section workaround in the user guide (#1847) that overrides newDialog. Compare both against the WAI-ARIA APG dialog pattern and the related WCAG audit (#1838). Done means the defaults emit role="dialog", aria-modal and an accessible name, move and restore focus, keep the rest of the page inert, plus a migration note and an updated guide section.

Written by the indexing model from the issue text.

Description

ModalDialog in wicket-extensions is not accessible out of the box. Focus handling is opt-in, and the dialog has no ARIA semantics, so screen readers don't announce it as a dialog. The accessibility chapter of the user guide (#1847, section "Dialogs") works around this by overriding newDialog. This issue asks to make that the dialog's default behaviour.

Current state:

  • The dialog element is a plain <div>. It has no role="dialog", no aria-modal="true" and no accessible name (WCAG 2.2 SC 4.1.2).
  • Focus trapping (trapFocus()) and Escape to close (closeOnEscape()) only work when the application calls them.
  • Content behind the overlay stays reachable for screen readers. Nothing makes it inert or aria-hidden while the dialog is open.

What an accessible version could do (see the WAI-ARIA APG dialog pattern):

  • Render role="dialog" and aria-modal="true", with a way to set aria-labelledby or aria-label, for instance from a title component in the content.
  • Move focus into the dialog when it opens, and give it back to the triggering element when it closes.
  • Consider making focus trapping and Escape to close the default, or using the native <dialog> element with showModal(), which provides most of this itself.
  • Update the user guide's "Dialogs" section once the workaround is no longer needed.

Changing the defaults affects existing applications, so the API and migration path need a decision in the PR.

Related: #1838 (WCAG 2.2 AA audit of the components).

Dominant language
Java
Stars
800
Forks
437
Avg merge
21h 36m
Merged PRs (30d)
167

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/wicket

All issues in apache/wicket

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.