Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

fix: Fix focusing on nullish modal elements #100

Merged
merged 1 commit into from
Aug 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Modal/ModalManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ function ModalManager({children}) {
// Focus the element that originally opened the modal
// There should only be one after a modal was un-registered)
useEffect(() => {
if (elementToFocus.current) {
// The timeout is needed to allow the focus lock script
// (react-focus-lock) to unlock the focus target
setTimeout(() => {
// The timeout is needed to allow the focus lock script
// (react-focus-lock) to unlock the focus target
setTimeout(() => {
if (elementToFocus.current) {
elementToFocus.current.focus();
elementToFocus.current = null;
}, 0);
}
}
}, 0);
}, [modalStack]);

// Apply aria-hidden to everything but the top-most modal.
Expand Down