diff --git a/src/app/utils.ts b/src/app/utils.ts index a4aed62c33..897b412140 100644 --- a/src/app/utils.ts +++ b/src/app/utils.ts @@ -1,3 +1,4 @@ +import { Document } from '@openstax/types/lib.dom'; import React, { Ref } from 'react'; import { getType } from 'typesafe-actions'; import { ApplicationError, ToastMesssageError } from '../helpers/applicationMessageError'; @@ -122,6 +123,14 @@ export const getAllRegexMatches = (regex: RegExp) => { }; }; +export const resetTabIndex = (document: Document) => { + const index = document.body.tabIndex; + document.body.tabIndex = 0; + + document.body.focus(); + document.body.tabIndex = index; +}; + export const preventDefault = (event: React.MouseEvent) => { event.preventDefault(); return event;