From c8d4d58a72b2750dcf1409c2036f1cd65834ea64 Mon Sep 17 00:00:00 2001 From: Bernt Christian Egeland Date: Sat, 28 Aug 2021 21:35:48 +0200 Subject: [PATCH] cleaned up --- web/src/components/AppBar.jsx | 3 ++- web/src/index.css | 2 +- web/src/routes/Event.jsx | 8 ++++++++ web/src/routes/Events/components/tableRow.jsx | 2 +- web/src/routes/Events/hooks/useClickOutside.jsx | 3 ++- web/src/routes/Events/index.jsx | 2 +- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/web/src/components/AppBar.jsx b/web/src/components/AppBar.jsx index 567fe291d..1003fee55 100644 --- a/web/src/components/AppBar.jsx +++ b/web/src/components/AppBar.jsx @@ -37,7 +37,8 @@ export default function AppBar({ title: Title, overflowRef, onOverflowClick }) { return (
{ + // When opening new event window, the previous one will sometimes cause the + // navbar to be visible, hence the "hide nav" code bellow. + // Navbar will be hided if we add the - translate - y - full class.appBar.js + console.log('getElementById'); + let element = document.getElementById('appbar'); + element.classList.add('-translate-y-full'); + }; }, [data, scrollRef, eventId, shouldScroll]); const handleClickDelete = () => { diff --git a/web/src/routes/Events/components/tableRow.jsx b/web/src/routes/Events/components/tableRow.jsx index d4e58669c..882a281ae 100644 --- a/web/src/routes/Events/components/tableRow.jsx +++ b/web/src/routes/Events/components/tableRow.jsx @@ -43,7 +43,7 @@ const EventsRow = memo( const start = new Date(parseInt(startTime * 1000, 10)); const end = new Date(parseInt(endTime * 1000, 10)); - console.log('tablerow has been rendered'); + // console.log('tablerow has been rendered'); return ( diff --git a/web/src/routes/Events/hooks/useClickOutside.jsx b/web/src/routes/Events/hooks/useClickOutside.jsx index d0e5d133c..2511d5b77 100644 --- a/web/src/routes/Events/hooks/useClickOutside.jsx +++ b/web/src/routes/Events/hooks/useClickOutside.jsx @@ -1,5 +1,6 @@ import { useCallback, useEffect, useRef, useState } from 'preact/hooks'; +// https://stackoverflow.com/a/54292872/2693528 export const useOuterClick = (callback) => { const callbackRef = useRef(); // initialize mutable ref, which stores callback const innerRef = useRef(); // returned to client, who marks "border" element @@ -15,7 +16,7 @@ export const useOuterClick = (callback) => { function handleClick(e) { if (innerRef.current && callbackRef.current && !innerRef.current.contains(e.target)) callbackRef.current(e); } - }, []); // no dependencies -> stable click listener + }, []); return innerRef; // convenience for client (doesn't need to init ref himself) }; diff --git a/web/src/routes/Events/index.jsx b/web/src/routes/Events/index.jsx index 22e677144..0597b230f 100644 --- a/web/src/routes/Events/index.jsx +++ b/web/src/routes/Events/index.jsx @@ -81,7 +81,7 @@ export default function Events({ path: pathname, limit = API_LIMIT } = {}) { [apiHost, handleFilter, pathname, scrollToRef] ); - console.log('main render'); + // console.log('main render'); return (
Events