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.

menu: focus lost when opening with keyboard and first item is disabled #12054

Closed

Description

@SemLR

Bug Report

When first item from an md-menu-content is disabled, the item container is not getting focus. Forbidding keyboard-only usage.

Demo and steps to reproduce the issue

Codepen demo

Detailed Reproduction Steps

  1. Open Above link
  2. Click near first phone icon
  3. Press tab key to give focus to md-menu
  4. Press Enter to open menu
  5. Try to reach one of enabled button

Explain the expected behavior

When opening via keyboard an md-menu, Focus should be get by first Button which is not disabled, even if md-content is filled with custom menu-item.

Explain the current behavior

Focus seems do be kept by menu button if first md-menu custom item is disabled.

List the affected versions of AngularJS, Material, OS, and browsers

  • AngularJS: 1.7.9 to current
  • AngularJS Material: from 1.1.20 to current
  • OS: GnuLinux Debian based distrib
  • Browsers: Chromium

Activity

  1. added
    needs triage
    on Dec 10, 2020
  2. changed the title [-][md-menu] - Focus lost when opening with keyboard and first item Button is disabled[/-] [+]menu: focus lost when opening with keyboard and first item button is disabled[/+] on Dec 13, 2020
  3. self-assigned this
    on Dec 13, 2020
  4. added
    a11y
    on Dec 13, 2020
  5. added this to the 1.2.2 milestone on Dec 13, 2020
  6. added
    P3: important
    and removed
    needs triage
    on Dec 13, 2020
  7. changed the title [-]menu: focus lost when opening with keyboard and first item button is disabled[/-] [+]menu: focus lost when opening with keyboard and first item is disabled[/+] on Dec 13, 2020
  8. added
    needs: investigation
    and removed
    needs: investigation
    P3: important
    on Dec 13, 2020
  9. Splaktar commented on Dec 14, 2020

    @Splaktar
    Contributor

    This seems to work properly when using md-button inside of your md-menu-items. Working Demo

    I'm not sure what library this is from:

              <a-menu-action label="item" is-disabled="$index == 0">
                </a-menu-action>

    But it doesn't appear to be compatible with md-menu without some custom styling (width is too short) and event handling (md-menu's built in focus handling requires md-button elements).

  10. 2 remaining items

  11. removed this from the 1.2.2 milestone on Dec 14, 2020
  12. SemLR commented on Dec 14, 2020

    @SemLR
    Author

    @Splaktar thank you for your attention to this problem.
    The component that is used is not part of a specific library and is declared alongside in the codepen. This Codepen is the simplest example showing the problem we are facing, when using components other than md-menu-item.
    I confirm that the component works well with menu-item but not with other components.

    The documentation clearly states: "Typically this will contain md-menu-items, but you can do custom content as well."

    The provided component relies internally on an md-button, whose focus is correctly recovered if it is first and non-disabled, but not if after a disabled md-button in the list.
    Does it make sense, and am i clear enough to point the problem ?

  13. added
    needs: investigation
    and removed
    resolution: works as expected
    on Dec 14, 2020
  14. added this to the 1.2.2 milestone on Dec 14, 2020
  15. added
    P3: important
    on Dec 14, 2020
  16. added a commit that references this issue on Dec 15, 2020
    b397329
  17. Splaktar commented on Dec 15, 2020

    @Splaktar
    Contributor

    Thank you for the heads up on that custom component, I didn't see it there at the bottom of the JS in CodePen.

    I've updated my demo to get the styling fixed and to use an approach that we can support (ng-disabled on first child element of the md-menu-item).

    Currently, if we don't find a non-disabled .md-button in the first md-menu-item, we just check if it has a child element and that the child element's disabled property is falsy. However, this only works for HTML elements that have a disabled property (like button) and doesn't work for custom elements (AngularJS Components).

    In PR #12058, I've added support for checking the disabled attribute as well. This allows you to set ng-disabled or disabled on your <a-menu-action> element so that it will be skipped in the search for the first focusable md-menu-item after the menu is opened.

  18. added
    has: Pull Request
    and removed
    needs: investigation
    on Dec 15, 2020
  19. added a commit that references this issue on Dec 16, 2020
    6391b13
  20. SemLR commented on Dec 17, 2020

    @SemLR
    Author

    @Splaktar Thank you for your attention and your responsiveness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3: importanta11yhas: Pull Requestresolution: fixedui: focus

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions