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

Remove timeout from ButtonModel a11yClick #371

Closed
jessegreenberg opened this issue Jul 26, 2018 · 4 comments
Closed

Remove timeout from ButtonModel a11yClick #371

jessegreenberg opened this issue Jul 26, 2018 · 4 comments
Assignees

Comments

@jessegreenberg
Copy link
Contributor

a11yClick was introduced as a way to implement accessibility in the button model. Motivated originally by #323. When using a screen reader or assistive device, clicking a button with the keyboard often doesn't register a keydown and keyup event, rather the user agent sends a single click event to the browser.

Because of this, we update the overProperty and downProperty using a timeout to update the look of the button and fire the listeners from the only event that we have access too.

But of course this timeout is causing problems. Particularly, we are running into a case using ?fuzzBoard where a Dialog can be closed and open again before being fully hidden, and so we are adding the same listeners to the open dialog more than once. But the issue is not specific to Dialog.

This issue is related to phetsims/scenery#831, where we are seeing if we can leverage PressListener for accessibility. Either way, we would like to remove the timeout from ButtonModel. @zepumph and I brainstormed ways around this. One solution would be to handle keydown and keyup when those events are available, and falling back on click where necessary. An input listener might look like

{
  keydown: function() {
    model.downProperty.set( true );
    keydownHandled = true;
  }
  keyup: function() {
    self.downProperty.set( false );
    keydownHandled = false;
  },
  click: function() {

    // receiving a click event without a related keydown/keyup event.
    if ( !keydownHandled ) {
      model.overProperty.set( true );
      model.downProperty.set( true );
      model.downProperty.set( false );
    }
  },
  focus: function() {
    model.overProperty.set( true );
  },
  blur: function() {
    model.overProperty.set( false );
  }
}

We might create this listener in a similar way to the current ButtonModel.createListener, so that a11y button functionality could be added to any node with a ButtonModel.

The drawback to this approach is that when using an AT that does not send keydown/keyup events to the browser (like switch devices, some gesture input, and maybe even JAWS - need to test) we won't see the button look pressed, it will fire but look flat.

@zepumph
Copy link
Member

zepumph commented Jul 26, 2018

Maybe @jonathanolson has insight, we can try to talk about this issue too tomorrow with him, when we meet for phetsims/scenery#831

@jessegreenberg
Copy link
Contributor Author

After more discussion in phetsims/scenery#831, we are going to try to use PressListener for a11y. Since the implementation will be in that type, we can better handle cases like the one the motivated this issue originally. Because of that, we decided that we should proceed with the timeout because it generally handles the input from AT in the most general way. @zepumph I am going to close this issue, but feel free to reopen if you think there is more to discuss here.

@zepumph
Copy link
Member

zepumph commented Jul 27, 2018

Actually I'm still unsure about this, the error we were getting on Wednesday is all about how the timer was delaying, async, too long, so we got weird logic where the dialog and phetmenu were both showing. I'm not yet clear how phetsims/scenery#831 could solve that.

@zepumph
Copy link
Member

zepumph commented Sep 24, 2018

This is handled as part of phetsims/scenery#831. Closing

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

No branches or pull requests

2 participants