Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Tweak roving tab index focus behaviour (#7254)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Dec 2, 2021
1 parent 0afe141 commit 68604e3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/accessibility/RovingTabIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ export const reducer = (state: IState, action: IAction) => {
state.activeRef = findSiblingElement(state.refs, oldIndex)
|| findSiblingElement(state.refs, oldIndex, true);
}
state.activeRef?.current?.focus();
if (document.activeElement === document.body) {
// if the focus got reverted to the body then the user was likely focused on the unmounted element
state.activeRef?.current?.focus();
}
}

// update the refs list
Expand Down

0 comments on commit 68604e3

Please sign in to comment.