diff --git a/src/App.tsx b/src/App.tsx index 5f010b33..fbd975ed 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,13 +1,24 @@ import { MainScene } from '@/scenes'; -import { useThemeContext } from './core/providers'; +import { + CanvasSchemaProvider, + CanvasViewSettingsProvider, + ModalDialogProvider, + useThemeContext, +} from './core/providers'; function App() { const { theme } = useThemeContext(); return ( -
- -
+ + + +
+ +
+
+
+
); } diff --git a/src/common/components/modal-dialog/modal-dialog.component.tsx b/src/common/components/modal-dialog/modal-dialog.component.tsx index 8b9bbce4..7c0cc4a6 100644 --- a/src/common/components/modal-dialog/modal-dialog.component.tsx +++ b/src/common/components/modal-dialog/modal-dialog.component.tsx @@ -2,19 +2,42 @@ import React from 'react'; import styles from './modal-dialog.styles.module.css'; import { useModalDialogContext } from '@/core/providers/modal-dialog-provider'; import { AnimatePresence, motion } from 'framer-motion'; +import { + handleEscapeKeyDown, + handleFocus, + handleNextFocus, + handleTabsInsideDialog, +} from './modal.dialog.bussines'; export const ModalDialog: React.FC = () => { const { closeModal, modalDialog } = useModalDialogContext(); + const containerRef = React.useRef(null); + const previousFocusedElement = React.useRef(null); + const handleClick = () => { closeModal(); }; + const handleEscapeKeyDownEvent = (e: KeyboardEvent) => + handleEscapeKeyDown(e, closeModal); + + const handleTabsInsideDialogEvent = (e: KeyboardEvent) => + handleTabsInsideDialog(e, containerRef); + React.useEffect(() => { if (modalDialog.isOpen) { document.body.classList.add('overflow-hidden'); + document.addEventListener('keydown', handleEscapeKeyDownEvent); + document.addEventListener('keydown', handleTabsInsideDialogEvent); + handleFocus(previousFocusedElement, containerRef); + } else { + handleNextFocus(previousFocusedElement); } + return () => { document.body.classList.remove('overflow-hidden'); + document.removeEventListener('keydown', handleEscapeKeyDownEvent); + document.removeEventListener('keydown', handleTabsInsideDialogEvent); }; }, [modalDialog.isOpen]); @@ -36,10 +59,19 @@ export const ModalDialog: React.FC = () => { animate={{ opacity: 1, scale: 1 }} exit={{ opacity: 0, scale: 0.8 }} transition={{ duration: 0.4 }} + ref={containerRef} + tabIndex={-1} + aria-labelledby="modal-modal-title" >
-

{modalDialog.title}

-