Skip to content

Commit

Permalink
fix(listitem): accessibility within listitem
Browse files Browse the repository at this point in the history
  • Loading branch information
yalo authored and bfbiggs committed Jun 10, 2020
1 parent c8e663e commit 2e5bcb7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions react/src/lib/ListItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,16 @@ class ListItem extends React.Component {
handleBlur = (e, focusLockTabbableChildren, tabbableChildrenQuery) => {
const { onBlur } = this.props;

// For when you click or navigate away from the current listitem
// Cleans up tabindex="0" before you navigate away
if (focusLockTabbableChildren) {
if (e.target) {
const currListItem = e.target.closest('.md-list-item');
const tabbableChildren = currListItem.querySelectorAll(tabbableChildrenQuery);
if (currListItem && tabbableChildren.length) {
if (e.relatedTarget) {
const newFocus = e.relatedTarget.closest('.md-list-item');
// If the element that is going to get focus is not the current listitem or the children in it
if (newFocus && currListItem !== newFocus) {
this.changeTabIndex(tabbableChildren, -1);
}
Expand Down

0 comments on commit 2e5bcb7

Please sign in to comment.