mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
fix: hydration errors for modifier key
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import type { HTMLAttributes } from 'react';
|
import type { HTMLAttributes } from 'react';
|
||||||
import { useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
import { Search } from 'lucide-react';
|
import { Search } from 'lucide-react';
|
||||||
|
|
||||||
@ -15,11 +15,14 @@ export type DesktopNavProps = HTMLAttributes<HTMLDivElement>;
|
|||||||
export const DesktopNav = ({ className, ...props }: DesktopNavProps) => {
|
export const DesktopNav = ({ className, ...props }: DesktopNavProps) => {
|
||||||
// const pathname = usePathname();
|
// const pathname = usePathname();
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
const [modifierKey, setModifierKey] = useState(() => 'Ctrl');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
const userAgent = typeof navigator !== 'undefined' ? navigator.userAgent : 'unknown';
|
const userAgent = typeof navigator !== 'undefined' ? navigator.userAgent : 'unknown';
|
||||||
|
|
||||||
const isMacOS = /Macintosh|Mac\s+OS\s+X/i.test(userAgent);
|
const isMacOS = /Macintosh|Mac\s+OS\s+X/i.test(userAgent);
|
||||||
const modifierKey = isMacOS ? '⌘' : 'Ctrl';
|
|
||||||
|
setModifierKey(isMacOS ? '⌘' : 'Ctrl');
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -39,7 +42,7 @@ export const DesktopNav = ({ className, ...props }: DesktopNavProps) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div className="text-muted-foreground bg-muted rounded-md px-1.5 py-0.5 font-mono text-xs">
|
<div className="text-muted-foreground bg-muted flex items-center rounded-md px-1.5 py-0.5 text-xs tracking-wider">
|
||||||
{modifierKey}+K
|
{modifierKey}+K
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user