-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Menu][Divider] Divider gets tabIndex 0 when all menu items are disabled #37306
Comments
Is there any reason aside maybe the spacing, why you used the |
The tabIndex is calculated programmatically, as shown here. Since the Divider is a child of the Menu, and with all the menu items disabled, it is assigned a tabIndex value of 0. I agree that this is a bug. In my opinion, the optimal solution would be to identify the Divider in children and avoid assigning a tabIndex to it. |
@ZeeshanTamboli I have the bandwidth to solve this bug if this is ready to be picked up |
@divyammadhok Feel free to work on it. If it is marked as a bug and nobody is working on it, it is ready to be picked up. :) |
@ZeeshanTamboli I've raised a PR addressing the fix, please take a look whenever you get some time - #38102 Thanks! |
Could the fix be as simple as adding |
@mnajdova Sure, I will look into this. Although, the current implementation was done thinking to make this reusable in scenarios where we may see more such elements that get focussed. I did test the current implementation by using different elements and making custom component wrappers which worked. The only issue was the if we depend on Would definitely check out |
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example:
https://codesandbox.io/s/vigorous-bas-2g9yfj?file=/demo.tsx
Steps:
<Menu>
with only disabled<MenuItem>
's,<Divider/>
,Tab
and see focus on divider.Current behavior 😯
If a list of menu items also contains a divider, and all menu items are disabled,
tabindex=0
will be set on the divider.Expected behavior 🤔
A divider should never get
tabindex=0
, unless explicitly programmed to do so.Context 🔦
Depending on user rights (user, admin, dev) or state (data isn't loaded yet, a save is in progress, or an underlying error), a menu item can either be
enabled
ordisabled
. Whenever there is no option available, all menu items could bedisabled
. If a menu contains a divider, keyboard navigation will focus on this divider, even though this should not be an element that gets focus.The text was updated successfully, but these errors were encountered: