You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
Repository navigation
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
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
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
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).
@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 ?
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.
Activity
[-][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[/+][-]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[/+]Splaktar commentedon Dec 14, 2020
This seems to work properly when using
md-buttoninside of yourmd-menu-items. Working DemoI'm not sure what library this is from:
But it doesn't appear to be compatible with
md-menuwithout some custom styling (width is too short) and event handling (md-menu's built in focus handling requiresmd-buttonelements).2 remaining items
SemLR commentedon Dec 14, 2020
@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 ?
fix(menu): menu focus is lost when menu-item has custom content
Splaktar commentedon Dec 15, 2020
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-disabledon first child element of themd-menu-item).Currently, if we don't find a non-disabled
.md-buttonin the firstmd-menu-item, we just check if it has a child element and that the child element'sdisabledproperty is falsy. However, this only works for HTML elements that have a disabled property (likebutton) and doesn't work for custom elements (AngularJS Components).In PR #12058, I've added support for checking the
disabledattribute as well. This allows you to setng-disabledordisabledon your<a-menu-action>element so that it will be skipped in the search for the first focusablemd-menu-itemafter the menu is opened.fix(menu): menu focus is lost when menu-item has custom content
SemLR commentedon Dec 17, 2020
@Splaktar Thank you for your attention and your responsiveness.