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

fix: duplicate modal instances from hotkey activation #1058

Merged
merged 10 commits into from
Apr 16, 2024
15 changes: 5 additions & 10 deletions apps/web/src/components/(dashboard)/layout/desktop-nav.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import type { HTMLAttributes } from 'react';
import { useEffect, useState } from 'react';

Expand All @@ -12,8 +10,6 @@ import { getRootHref } from '@documenso/lib/utils/params';
import { cn } from '@documenso/ui/lib/utils';
import { Button } from '@documenso/ui/primitives/button';

import { CommandMenu } from '../common/command-menu';

const navigationLinks = [
{
href: '/documents',
Expand All @@ -25,13 +21,14 @@ const navigationLinks = [
},
];

export type DesktopNavProps = HTMLAttributes<HTMLDivElement>;
export type DesktopNavProps = HTMLAttributes<HTMLDivElement> & {
setIsCommandMenuOpen: (value: boolean) => void;
};

export const DesktopNav = ({ className, ...props }: DesktopNavProps) => {
export const DesktopNav = ({ className, setIsCommandMenuOpen, ...props }: DesktopNavProps) => {
const pathname = usePathname();
const params = useParams();

const [open, setOpen] = useState(false);
const [modifierKey, setModifierKey] = useState(() => 'Ctrl');

const rootHref = getRootHref(params, { returnEmptyRootString: true });
Expand Down Expand Up @@ -70,12 +67,10 @@ export const DesktopNav = ({ className, ...props }: DesktopNavProps) => {
))}
</div>

<CommandMenu open={open} onOpenChange={setOpen} />

<Button
variant="outline"
className="text-muted-foreground flex w-96 items-center justify-between rounded-lg"
onClick={() => setOpen((open) => !open)}
onClick={() => setIsCommandMenuOpen(true)}
>
<div className="flex items-center">
<Search className="mr-2 h-5 w-5" />
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/(dashboard)/layout/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const Header = ({ className, user, teams, ...props }: HeaderProps) => {
<Logo className="h-6 w-auto" />
</Link>

<DesktopNav />
<DesktopNav setIsCommandMenuOpen={setIsCommandMenuOpen} />

<div className="flex gap-x-4 md:ml-8">
<MenuSwitcher user={user} teams={teams} />
Expand Down
Loading