Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

md-toolbar and sidenav focus problems #5563

Closed

Description

@devversion

For testing purposes I tried to create a sidenav, which should be triggered by the toolbar
But as you can see in the bad quality GIF, the css class is-focused will be added after dismissing the sidebar. So I already checked the code and I found this snippet

return $q(function(resolve){
  // Toggle value to force an async `updateIsOpen()` to run
  scope.isOpen = isOpen;

  $mdUtil.nextTick(function() {
    // When the current `updateIsOpen()` animation finishes
    promise.then(function(result) {

      if ( !scope.isOpen ) {
        // reset focus to originating element (if available) upon close
        triggeringElement && triggeringElement.focus();
        triggeringElement = null;
      }

      resolve(result);
    });
  });

});

gif

I already fixed that in my version, but I want to ask the development team first about their thoughts.
So I created a merge for that, please take a look at it and tell me more about potential side-affects

@jelbourn @ThomasBurleson

Activity

  1. added 2 commits that reference this issue on Nov 4, 2015
    942e668
    7c42b02
  2. devversion commented on Nov 4, 2015

    @devversion
    MemberAuthor

    I referenced my both commits :) please take a look :)

    With Fix 2, you simply need to add the flag nofocus to the md-button

    angular
    This happens too, on the docs

  3. modified the milestone: 1.0-rc4 on Nov 5, 2015
  4. jelbourn commented on Nov 5, 2015

    @jelbourn
    Contributor

    cc @marcysutton

    I believe that focus is there on purpose for accessibility reasons (indicates to keyboard users where the focus is).

  5. devversion commented on Nov 5, 2015

    @devversion
    MemberAuthor

    That's why I thought about creating an extra attribute which prevents focus recovery.
    What do you think about that?

    If you found a good solution, you can tell me :)

  6. marcysutton commented on Nov 5, 2015

    @marcysutton
    Contributor

    Rather than providing a way to break accessibility, a proper solution for this would involve something like #5189: only show the focus style on keyboard interaction. Mouse users wouldn't see it. We definitely should not provide hooks to disable accessibility features, but rather apply those features in more specific ways.

  7. devversion commented on Nov 5, 2015

    @devversion
    MemberAuthor

    https://github.com/ten1seven/what-input

    That isn't a good solution for detecting the interaction type, because then I need to bind a listener on the triggeringElement. The Problem with binding the listener to the element is: I only get the current triggeringElement after the event is already triggered, so this would be useless.

    Should I instead check for the global input methods? (like: touch or mouse)

  8. marcysutton commented on Nov 5, 2015

    @marcysutton
    Contributor

    Did you look at the library? It is checking global input methods. Consumers of the library don't have to do anything except include it and write some CSS. That said, I didn't think we would necessarily use a third-party lib in Angular Material, but I wanted to float it up as an example.

  9. devversion commented on Nov 5, 2015

    @devversion
    MemberAuthor

    Yeah, I took a look at it ;), so we should provide an own version of that with less features?

  10. marcysutton commented on Nov 5, 2015

    @marcysutton
    Contributor

    That's the idea, yes. We don't need the full event API, just input detection allowing us to apply focus styles on keyboard interaction only.

  11. added a commit that references this issue on Nov 5, 2015
    f4d2b33
  12. devversion commented on Nov 5, 2015

    @devversion
    MemberAuthor

    I created a PR, I already tested it on my local environment. Now it only restores the focus if I trigger the sidenav with keyboard.

    If there are any suggestions please tell me

  13. 47 remaining items

  14. modified the milestones: , 1.1.1 on Apr 21, 2016
  15. added a commit that references this issue on Apr 22, 2016
    12f7f0f
  16. cmacdonnacha commented on May 30, 2016

    @cmacdonnacha

    Hey,

    Just wondering what the status on this? I'm currently seeing the same behavior where focus is still set to the button after closing the sidenav.

    Thanks!

  17. devversion commented on May 30, 2016

    @devversion
    MemberAuthor

    @cmacdonnacha Yeah, it's unfortunately still pending.

  18. cmacdonnacha commented on May 31, 2016

    @cmacdonnacha

    @devversion Thanks for the update.

  19. added
    has: Pull Request
    and removed
    pr: merge ready
    on Aug 24, 2016
  20. ThomasBurleson commented on Aug 24, 2016

    @ThomasBurleson
    Contributor

    @devversion - what is the PR associated with this issue ?

  21. devversion commented on Aug 24, 2016

    @devversion
    MemberAuthor
  22. added a commit that references this issue on Aug 26, 2016
    7ea6489
  23. added a commit that references this issue on Sep 19, 2016
    8e8c6a6
  24. added a commit that references this issue on Oct 12, 2016
    24370e7
  25. removed this from the - Backlog milestone on Feb 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

has: Pull Request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions