Tweak roving tab index focus behaviour (#7254)

pull/21833/head
Michael Telatynski 2021-12-02 10:24:55 +00:00 committed by GitHub
parent 0afe141266
commit 68604e3505
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -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