mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2025-12-06 12:20:20 +01:00
21 lines
531 B
TypeScript
21 lines
531 B
TypeScript
import { focusClosestFocusableElement } from '@/utils/elements';
|
|
import { useEffect } from 'react';
|
|
|
|
const useIFrameFocuser = (): void => {
|
|
const focusIFrameContainer = () => {
|
|
if (document.activeElement instanceof HTMLIFrameElement) {
|
|
focusClosestFocusableElement(document.activeElement);
|
|
}
|
|
};
|
|
|
|
useEffect(() => {
|
|
window.addEventListener('blur', focusIFrameContainer);
|
|
|
|
return () => {
|
|
window.removeEventListener('blur', focusIFrameContainer);
|
|
};
|
|
}, []);
|
|
};
|
|
|
|
export default useIFrameFocuser;
|