Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More abstraction for accessible components #607

Closed
Tracked by #953
jessegreenberg opened this issue Feb 10, 2017 · 7 comments
Closed
Tracked by #953

More abstraction for accessible components #607

jessegreenberg opened this issue Feb 10, 2017 · 7 comments
Assignees

Comments

@jessegreenberg
Copy link
Contributor

In phetsims/john-travoltage#149 @jonathanolson said:

It may make sense long-term to think about mix-ins for specific component types.
For instance, say you have a Path that you want to be a slider in the DOM. You need:

tagName: 'input',
inputType: 'range',
ariaRole: 'slider',

set, possibly parentContainerTagName: 'div' or others, you'll want the workaround:

// Safari seems to require that a range input has a width, otherwise it will not be keyboard accessible.
this.domElement.style.width = '1px';

you'll want to handle the min/max/step attributes, etc., and maybe custom slider-related functions would be good (handles a Range and a Property{number}).

Now say you want to do that for a Text element.
It makes sense to be able to mix in this "AccessibleSlider" behavior into any Node, e.g.:

AccessibleSlider.mixin( AppendageNode ); // after the inherit

and

this.initializeAccessibleSlider( ... ); // somewhere in the constructor

where the mixin can handle hooking up all of the events (change/input/blur) into a Property{number} value and Property{boolean} dragged that clients can use.
Also I'd note that this is the typical case of mix-ins, where you need to add in behavior (acting like a slider) to any point in a normal inheritance hierarchy.

@jessegreenberg
Copy link
Contributor Author

Is there a precedent for conditionally mixing something in? For instance, say sun/HSlider mixes in AccessibleSlider, which sets the accessible content and adds axon/Properties for clients.

But if in some context we want a sun/HSlider to look like

<div role="slider" tabindex="0></div>

with a custom set of listeners and Properties, we could have changes to the HSlider prototype or other things that we don't want.

@jessegreenberg
Copy link
Contributor Author

@jonathanolson responded with:

HSlider as a type would either have it mixed in or not. If the flexibility is warranted, you would either:

  • Not have it mix it in, and have clients do so. This may be helpful if you need customizable mixins with parameters, e.g. AccessibleSlider.mixin( HSliderSubtype, { options } ).
  • Have another mixin which overrides some of AccessibleSlider's behavior.

@jessegreenberg
Copy link
Contributor Author

I really like the first suggestion in #607 (comment). It seems useful to be able to customize the accessible component with options, so that any portion of the content can be changed, rather than overriding specific behavior with another mixin.

@jessegreenberg
Copy link
Contributor Author

jessegreenberg commented Feb 10, 2017

We should investigate and see how this feels, but I am wondering if this pattern would be overkill for the majority of accessible content. For instance, to create a button with the Accessibility mixin, you might do

Node.call( this, {
  // a11y options
  tagName: 'input'
  inputType: 'button'
  accessibleLabel: 'Translatable Label'
} );

this.addAccessibleInputListener( { click: clickListener } );

Sliders are more complex, but most input elements tend to be this simple.

@jessegreenberg
Copy link
Contributor Author

With the first bullet in #607 (comment), we might have

// in the constructor
this.initializeAccessibleButton( {
  accessibleLabel: 'Translatable Label',
  listener: clickListener
} );

// outside of constructor
AccessibleButton.mixin( MyButtonNode );

@zepumph
Copy link
Member

zepumph commented May 11, 2018

This relates highly to our work during this week's a11y sprint. Adding to a11y meeting.

@zepumph
Copy link
Member

zepumph commented Jul 23, 2021

@jessegreenberg and I discussed this outdated issue today. There is nothing left here, we now have multiple mixins for a11y technology.

@zepumph zepumph closed this as completed Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants