Skip to content

Commit 79d9ce8

Browse files
committed
feat(web): close miniguides when clicking outside container
1 parent a3f5a66 commit 79d9ce8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

web/src/components/Popup/MiniGuides/Template.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import React, { Dispatch, SetStateAction } from "react";
1+
import React, { Dispatch, SetStateAction, useRef } from "react";
22
import styled, { css } from "styled-components";
33
import { landscapeStyle } from "styles/landscapeStyle";
44
import { CompactPagination } from "@kleros/ui-components-library";
55
import { Overlay } from "components/Overlay";
66
import BookOpenIcon from "tsx:assets/svgs/icons/book-open.svg";
7+
import { useFocusOutside } from "hooks/useFocusOutside";
78

89
const Container = styled.div`
910
display: flex;
@@ -123,10 +124,14 @@ const Template: React.FC<ITemplate> = ({
123124
setCurrentPage,
124125
numPages,
125126
}) => {
127+
const containerRef = useRef(null);
128+
useFocusOutside(containerRef, () => {
129+
onClose();
130+
});
126131
return (
127132
<>
128133
<Overlay />
129-
<Container>
134+
<Container ref={containerRef}>
130135
<LeftContainer>
131136
<HowItWorks>
132137
<BookOpenIcon />

0 commit comments

Comments
 (0)