Add screen reader accessibility guidance and framework-level helpers

Aperta
#7,294 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
javascript

Direzione di ricerca

Esamina innanzitutto il supporto di Phaser per DOM Elements tramite dom.createContainer e il limite di accessibilità di canvas/WebGL. Definisci se il contributo debba riguardare l’infrastruttura di accessibilità a livello di framework oppure linee guida ed esempi ufficiali; il lavoro sarà considerato completato quando sarà stato concordato un ambito che copra menu, cambi di scena, annunci e gestione del focus.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hi Phaser team. This is both a feature request and a general request for guidance. I had a quick look through your open issues for dupes, but couldn't find one.

Most Phaser game content is rendered to canvas/WebGL by default. Screen reader users are therefore unable to directly access menu and game-state content when it is implemented with Phaser Text objects, sprites, menu selections, and scene changes, because that content is rendered inside the canvas/WebGL output and is not represented in the browser accessibility tree.

Example of current markup, which behaves like a black-box for screenreaders:

<div id="game-container">
  <canvas width="1280" height="720"> Example Phaser game. </canvas>
</div>

I recognize this is fundamentally a browser/canvas limitation, and that Phaser cannot infer useful screen reader semantics from user-side assets like sprites.

I also saw that Phaser already supports DOM Elements through dom.createContainer, and that could be relevant to a final implementation strategy. The gap I'm running into is that I couldn't find official guidance or examples for using that feature to expose screen reader semantics for the canvas-rendered game UI.

To improve screen reader experience you'd need to manually construct a parallel DOM layer alongside the Phaser game canvas. This would include:

  • visually-hidden DOM that mirrors Phaser menus
  • ARIA live regions for scene changes and gameplay events
  • imperative and manual focus management
  • callbacks from every menu, dialog, HUD, and state change so the hidden DOM stays in sync.

While that could be done, it is a lot of duplicated infra and really brittle as it could lead to state-drift.

Would Phaser be open to providing framework-level features for better accessibility semantics?

Here's an example of an API that could be worth exploring:

this.accessibility.setSceneDescription("Main menu");

startText.setAccessible({
  role: "button",
  label: "Start Game",
  focusable: true,
  selected: true,
  onActivate: () => this.startGame(),
});

this.accessibility.announce("Wave 1 starting", { priority: "polite" });

The game authors would still provide the labels, roles, states, and announcement text.

Phaser could then provide the associated DOM/live-region/focus plumbing. This would mean that downstream users don't need to manage the hidden DOM mirror manually.

Some guides on your website or in the repo would be equally helpful, particularly if there's an alternative approach that you recommend.

Optional: Do you want to help provide this feature?

Happy to open a PR if that's helpful, though I'd like to validate my assumptions first.


Thanks in advance. Big fan of the framework, keep up the great work! 💖

Lingua principale
JavaScript
Stelle
40.7k
Fork
7.2k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di phaserjs/phaser

Tutte le issue di phaserjs/phaser

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.