Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

front: only display content after JS is ready #3509

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
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
48 changes: 29 additions & 19 deletions front/components/sparkle/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Link from "next/link";
import { useRouter } from "next/router";
import Script from "next/script";
import { signOut } from "next-auth/react";
import React, { Fragment, useContext, useState } from "react";
import React, { Fragment, useContext, useEffect, useState } from "react";

import type {
SidebarNavigation,
Expand Down Expand Up @@ -224,6 +224,12 @@ export default function AppLayout({
children: React.ReactNode;
}) {
const { sidebarOpen, setSidebarOpen } = useContext(SidebarContext);
const [loaded, setLoaded] = useState(false);

useEffect(() => {
setLoaded(true);
}, []);

return (
<>
<Head>
Expand Down Expand Up @@ -332,14 +338,16 @@ export default function AppLayout({
</button>
</div>
</Transition.Child>
<NavigationBar
subscription={subscription}
owner={owner}
subNavigation={subNavigation}
topNavigationCurrent={topNavigationCurrent}
>
{navChildren && navChildren}
</NavigationBar>
{loaded && (
<NavigationBar
subscription={subscription}
owner={owner}
subNavigation={subNavigation}
topNavigationCurrent={topNavigationCurrent}
>
{navChildren && navChildren}
</NavigationBar>
)}
</Dialog.Panel>
</Transition.Child>
</div>
Expand All @@ -349,14 +357,16 @@ export default function AppLayout({

{!hideSidebar && (
<div className="hidden lg:fixed lg:inset-y-0 lg:z-0 lg:flex lg:w-80 lg:flex-col">
<NavigationBar
owner={owner}
subscription={subscription}
subNavigation={subNavigation}
topNavigationCurrent={topNavigationCurrent}
>
{navChildren && navChildren}
</NavigationBar>
{loaded && (
<NavigationBar
owner={owner}
subscription={subscription}
subNavigation={subNavigation}
topNavigationCurrent={topNavigationCurrent}
>
{loaded && navChildren && navChildren}
</NavigationBar>
)}
</div>
)}

Expand Down Expand Up @@ -390,7 +400,7 @@ export default function AppLayout({
>
<div className="grow">
<div className="mx-auto h-full grow px-6">
{titleChildren && titleChildren}
{loaded && titleChildren && titleChildren}
</div>
</div>
</div>
Expand Down Expand Up @@ -427,7 +437,7 @@ export default function AppLayout({
isWideMode ? "w-full" : "max-w-4xl px-6"
)}
>
{children}
{loaded && children}
</div>
</main>
</div>
Expand Down
88 changes: 44 additions & 44 deletions front/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"jsonwebtoken": "^9.0.0",
"minimist": "^1.2.8",
"moment-timezone": "^0.5.43",
"next": "^13.5.4",
"next": "^13.5.6",
"next-auth": "^4.18.10",
"next-remove-imports": "^1.0.8",
"pdfjs-dist": "^3.7.107",
Expand Down
Loading