Skip to content

Service for handling keyboard vs. mouse focus behavior #289

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

Closed
devversion opened this issue Apr 9, 2016 · 8 comments
Closed

Service for handling keyboard vs. mouse focus behavior #289

devversion opened this issue Apr 9, 2016 · 8 comments
Labels
Accessibility This issue is related to accessibility (a11y) feature This issue represents a new feature or feature request rather than a bug or bug fix
Milestone

Comments

@devversion
Copy link
Member

Currently, we always show a focus effect on the button component, when there was no mouse event the last 100ms.

This is really hard-coded and there are bugs. For example, switching browser tabs, is restoring focus and showing the focus-effect (should not happen).

A service for interaction, which detects the last interaction type would solve that issue very elegant and would be also helpful for other components.

I also implemented that in Material 1 (still pending after re-submit) and I would like to implement it in Material 2 as well.

So let me know if you need this, and I will implement it :)

@jelbourn jelbourn changed the title a11y: interaction service Service for handling keyboard vs. mouse focus behavior Apr 12, 2016
@jelbourn jelbourn added the Accessibility This issue is related to accessibility (a11y) label Apr 12, 2016
@jelbourn jelbourn added this to the before beta milestone Apr 12, 2016
@jelbourn
Copy link
Member

@devversion yeah, this would be nice to have. I think the better solution is to set a flag on touchstart / mousedown and use that on the focus event. Is that what your approach in ng1 did?

@devversion
Copy link
Member Author

@jelbourn - This is what we currently do in Material 1 and Material 2.

      scope.mouseActive = false;
      element.on('mousedown', function() {
        scope.mouseActive = true;
        $timeout(function(){
          scope.mouseActive = false;
        }, 100);
      })
      .on('focus', function() {
        if (scope.mouseActive === false) {
          element.addClass('md-focused');
        }
      })
      .on('blur', function(ev) {
        element.removeClass('md-focused');
      });

But this is an old approach and is not working probably anymore.
For example, if you click on a button and then you switch browser tabs, then the browser restores the focus (- but no mousedown event is triggered), so the button will become the md-focused class. (not valid)

I also created an issue on Material 1 a few days ago. Please take a look at it and the accompanying PR.

This service tracks the last interaction type and allows us to provide perfect accessibility on some components.

@jelbourn
Copy link
Member

Having a service would be good. Feel free to put together a PR!

@jelbourn jelbourn added the feature This issue represents a new feature or feature request rather than a bug or bug fix label Apr 12, 2016
@devversion
Copy link
Member Author

@jelbourn Awesome, will start that tomorrow 👍

devversion added a commit to devversion/material2 that referenced this issue Apr 14, 2016
devversion added a commit to devversion/material2 that referenced this issue Apr 14, 2016
devversion added a commit to devversion/material2 that referenced this issue Apr 14, 2016
@devversion
Copy link
Member Author

Just want to reference a few things here. The focus is currently accidentally showing up on Desktop Browsers, because the current workaround with the timeout is not working properly.

Once the Interaction Service will be approved / land, we will fix the following components:

  • Checkbox Focus Indicator
  • Slide-Toggle Focus Indicator
  • Radio Focus Indicator

cc. @jelbourn

@csabattilas
Copy link

Hi, It looks that the radio focus indicator is still broken or not there. Where can i take a look on this how to fix it or add this feature? thanks

@devversion
Copy link
Member Author

This should be fixed with the new focus-classes directive.

andrewseguin pushed a commit to andrewseguin/components that referenced this issue Oct 15, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Accessibility This issue is related to accessibility (a11y) feature This issue represents a new feature or feature request rather than a bug or bug fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants