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

fixes: errors hydration errors + re-adds vscode settings #44

Merged
merged 3 commits into from
Apr 24, 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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,4 @@ yarn-error.log*
next-env.d.ts

.contentlayer
.vscode
tsconfig.tsbuildinfo
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@
"unifiedjs.vscode-mdx",
"usernamehw.errorlens"
],
"typescript.tsdk": "node_modules/typescript/lib",
"cSpell.words": ["Timescape"]
"cSpell.words": ["nums", "timescape"],
"typescript.tsdk": "node_modules/typescript/lib"
}
14 changes: 11 additions & 3 deletions src/components/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const SearchPopOver = () => {
const router = useRouter();
const [isOpen, setIsOpen] = useState(false);
const [query, setQuery] = useState("");
const [mounted, setMounted] = useState(false);
const isMac = isMacOs();
useEffect(() => {
const down = (e: KeyboardEvent) => {
Expand Down Expand Up @@ -50,11 +51,18 @@ export const SearchPopOver = () => {
const handleSearch = (query: string) => {
setQuery(query);
};

useEffect(() => {
if (!isOpen) setQuery("");
}, [isOpen]);

return (
useEffect(() => {
if (mounted) return;
setMounted(true);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return mounted ? (
<>
<Button
variant="ghost"
Expand Down Expand Up @@ -87,7 +95,7 @@ export const SearchPopOver = () => {
/>
<CommandList>
<CommandEmpty className={cn("py-6 text-center text-sm")}>
No products found.
No documents found.
</CommandEmpty>
<CommandGroup
className="capitalize block md:hidden"
Expand Down Expand Up @@ -140,5 +148,5 @@ export const SearchPopOver = () => {
</CredenzaContent>
</Credenza>
</>
);
) : null;
};