Skip to content
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

TreeView programmatic focus does not change tab indices #20141

Closed
2 tasks done
tonyhallett opened this issue Mar 16, 2020 · 0 comments · Fixed by #20237
Closed
2 tasks done

TreeView programmatic focus does not change tab indices #20141

tonyhallett opened this issue Mar 16, 2020 · 0 comments · Fixed by #20237
Labels
bug 🐛 Something doesn't work component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module!

Comments

@tonyhallett
Copy link
Contributor

tonyhallett commented Mar 16, 2020

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

Call focus() on a tree item it does not affect the isTabbable of the newly focused tree item or any of the others.

Expected Behavior 🤔

The newly focused tree item has tabindex 0 and the previously focused has tabIndex -1

Steps to Reproduce 🕹

https://codesandbox.io/s/elastic-snow-ut9t7

Steps:

  1. Programmatically focus by pressing the 'Programmatic focus' button
  2. Shift Tab - tree item one has focus when it should be the button

https://github.com/mui-org/material-ui/blob/70c937d92dea4bd794164b4d75f75c1a84217363/packages/material-ui-lab/src/TreeItem/TreeItem.js#L331)

The tabbable variable prevents the expected behaviour.

const handleFocus = event => {
    if (!focused && tabbable) {
      focus(nodeId);
    }

    if (onFocus) {
      onFocus(event);
    }
  };

Is this some hacky way to circumvent React ?

@oliviertassinari oliviertassinari added the component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module! label Mar 16, 2020
@tonyhallett tonyhallett changed the title TreeView programmatic focus does not change tab indexes TreeView programmatic focus does not change tab indices Mar 21, 2020
@eps1lon eps1lon added the bug 🐛 Something doesn't work label Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants