diff --git a/src/bootstrap/Modal.js b/src/bootstrap/Modal.js index aee202b..a1e65c0 100644 --- a/src/bootstrap/Modal.js +++ b/src/bootstrap/Modal.js @@ -9,7 +9,7 @@ import React, { useRef, useEffect } from "react"; import PropTypes from "prop-types"; -import { useClickOutside } from "../utils/hooks"; +import { useClickOutside, useFocusTrap } from "../utils/hooks"; import Portal from "../utils/Portal"; import "./Modal.css"; @@ -29,10 +29,11 @@ Modal.propTypes = { }; export function Modal({ shown, setShown, scrollable, size, children }) { - const dialogRef = useRef(); + const modalRef = useRef(); let modalSize = "modal-"; - useClickOutside(dialogRef, () => setShown(false)); + useClickOutside(modalRef, () => setShown(false)); + useFocusTrap(modalRef, shown); useEffect(() => { const handleEsc = (event) => { @@ -65,11 +66,13 @@ export function Modal({ shown, setShown, scrollable, size, children }) { return (
-
{title}
+

{title}