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

problems with a11y and time-based buttons #931

Closed
pixelzoom opened this issue Jan 22, 2019 · 5 comments
Closed

problems with a11y and time-based buttons #931

pixelzoom opened this issue Jan 22, 2019 · 5 comments

Comments

@pixelzoom
Copy link
Contributor

Noted while working on phetsims/sun#447, and it's probably the root cause. a11y doesn't seem to have any way to prevent click from firing multiple time when the Enter key is held down.

PushButtonModel has these options:

      // fire-on-hold feature
      fireOnHold: false, // is the fire-on-hold feature enabled?
      fireOnHoldDelay: 400, // start to fire continuously after pressing for this long (milliseconds)
      fireOnHoldInterval: 100, // fire continuously at this interval (milliseconds), same default as in ButtonModel

These only pertain to the listener added via PushButtonModel addListener. A11y-specific listeners must currently be added via addInputListener, and have no knowledge of this fire-only-hold feature.

Example:

const myButton = new RectangularPushButton();
myButton.addListener( ... );

// Handle button clicks, for a11y
myButton.addInputListener( {
  click( event) { console.log( 'click' ); } 
} );

Since the default is fireOnHold: false, the click callback should fire once. But if you press and hold the Enter key, it will continue to fire until you release the Enter key.

@zepumph zepumph transferred this issue from phetsims/sun Jan 22, 2019
@zepumph
Copy link
Member

zepumph commented Jan 22, 2019

Transferred to scenery because hopefully we can come up with a general solution, since the current fire on hold is just supported by sun buttons.

@zepumph
Copy link
Member

zepumph commented Jan 28, 2019

Relates to phetsims/sun#424. To @jessegreenberg and @zepumph, the main piece for this issue is to have scenery support these options.

@zepumph
Copy link
Member

zepumph commented Feb 5, 2019

While discussing with @jessegreenberg yesterday, it came up that potentially a good place to put this functionality would be in FireListener, a child to PressListener. That listener is set up relatively similarly to how we support these options in PushButtonModel, and could help us more easily "control" the repeated browser events.

@jessegreenberg jessegreenberg changed the title problems with a11y and fireOnHold problems with a11y and time-based buttons Nov 17, 2020
@jessegreenberg
Copy link
Contributor

We came back to this issue on 11/17/20:

We discussed having a way to listen to both keydown/keyup events when a screen reader is not in use, and listen to click events when using a screen reader. But didn't like how that would make us responsible for two different behaviors depending on whether we are using an AT.

We also talked about being able to set the time between when the PressListener is pressed and when the PressListener is released in the click event. That way a single click could effectively press the button for any amount of time.

However, we decided that it would be incorrect to use click in some cases because only firing at a particular interval regardless of the number of click events received wont always work. For example, what if the "enter" key is legitimately pressed faster than the fire-on-hold delay? When we need this, we should be using keydown and keyup events directly, and we shouldn't be using a button in the PDOM. We think that PressListener needs an option to opt-out of the PDOM input listeners (click) and time-bassed buttons will set a different PDOM representation (with role=application) and add a listener that response to keydown and keyup events.

@jeseegreenberg and @zepumph think this is the right way forward, but had concerns that accessibility designers may disagree that time-based buttons should not be buttons in the PDOM. We will revisit this again when we are working on a sim that uses time-based buttons. Removing assignments and marking on-hold.

@jessegreenberg
Copy link
Contributor

#1117 will track adding support for this, closing this issue.

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

3 participants