From e2bee3ab9451809ea780cf4ab02fa82b02f2de96 Mon Sep 17 00:00:00 2001 From: Bernt Christian Egeland Date: Fri, 27 Aug 2021 21:47:51 +0200 Subject: [PATCH] re-arrange --- web/src/routes/Event.jsx | 20 +++- web/src/routes/Events/components/tableRow.jsx | 106 +++++------------- .../routes/Events/hooks/useSearchString.jsx | 18 ++- web/src/routes/Events/index.jsx | 102 ++++++++++------- 4 files changed, 111 insertions(+), 135 deletions(-) diff --git a/web/src/routes/Event.jsx b/web/src/routes/Event.jsx index 06025d75e..9bbd88ab8 100644 --- a/web/src/routes/Event.jsx +++ b/web/src/routes/Event.jsx @@ -1,5 +1,5 @@ import { h, Fragment } from 'preact'; -import { useCallback, useState, useEffect } from 'preact/hooks'; +import { useCallback, useState, useEffect, useRef } from 'preact/hooks'; import ActivityIndicator from '../components/ActivityIndicator'; import Button from '../components/Button'; import Clip from '../icons/Clip'; @@ -18,6 +18,7 @@ export default function Event({ eventId, close, scrollRef }) { const [shouldScroll, setShouldScroll] = useState(true); const [deleteStatus, setDeleteStatus] = useState(FetchStatus.NONE); const setDeleteEvent = useDelete(); + const eventRef = useRef(null); useEffect(() => { // Scroll event into view when component has been mounted. @@ -27,6 +28,21 @@ export default function Event({ eventId, close, scrollRef }) { } }, [data, scrollRef, eventId, shouldScroll]); + // useEffect(() => { + // const checkIfClickedOutside = (e) => { + // // If the event is open and the clicked target is not within the event window or delete modal, + // // then close the menu + // if (!showDialog && eventRef.current && !eventRef.current.contains(e.target)) { + // close(null); + // } + // }; + // document.addEventListener('mousedown', checkIfClickedOutside); + // return () => { + // // Cleanup the + // document.removeEventListener('mousedown', checkIfClickedOutside); + // }; + // }, [close, showDialog]); + const handleClickDelete = () => { setShowDialog(true); }; @@ -55,7 +71,7 @@ export default function Event({ eventId, close, scrollRef }) { } return ( -
+