phetsims / scenery-phet

Reusable components based on Scenery that are specific to PhET simulations.
http://scenerystack.org/
MIT License
9 stars 6 forks source link

Use accessibleName instead of innerContent. #875

Open pixelzoom opened 1 month ago

pixelzoom commented 1 month ago

Related to https://github.com/phetsims/models-of-the-hydrogen-atom/issues/67 ...

I'm creating this issue in scenery-phet, but it's relevant to all places where accessibleName should be used.

I asked about the different between innerContent and accessibleName. @jessegreenberg replied in Slack#DM:

In ParallelDOM.ts, we have a "lower level" and "higher level" API. The lower level is where we started, it lets you customize the markup in the PDOM quite a bit. The higher level is more simple, and lets you set things like the accessible name and help text without needing to understand the markup as much.

There is current inconsistency in which API is used. Some common-code components are setting innerContent instead of accessibleName. And this has been causing confusion while trying to implement accessible names in MOTHA https://github.com/phetsims/models-of-the-hydrogen-atom/issues/67. @jessegreenberg and I think that we should be using accessibleName (the higher-level API) whenever possible, which means changing innerContent to accessibleName.

An incomplete list of examples:

pixelzoom commented 1 month ago

Looks like the CloseButton change was pushed as part of work related to GrabDragInteraction: https://github.com/phetsims/scenery-phet/commit/4d7f8fbc55644792dedc6d5c73ea15426fc6b643

zepumph commented 1 month ago

You should look for usages of labelContent too as part of this issue.

In general I think this issue is quite simple, you just need to overwrite accessibleNameBehavior to forward the accessibleName value to where it should go. The default is defined here: https://github.com/phetsims/scenery/blob/bfa0d2e25d033cf44e688b2633f2492690f97df0/js/accessibility/pdom/ParallelDOM.ts#L3265-L3277

zepumph commented 1 month ago

Are we also going to have a similar issue in sun?

pixelzoom commented 1 month ago

@zepumph asked:

Are we also going to have a similar issue in sun?

Yes. In the first comment, I said:

I'm creating this issue in scenery-phet, but it's relevant to all places where accessibleName should be used.

pixelzoom commented 4 weeks ago

This issue overlaps with: