Skip to content

Commit

Permalink
Hide controls if no search results
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucieo committed Sep 14, 2023
1 parent c734c69 commit 8e64c20
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/bookmark/BookmarksListControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ export const BookmarksListControls = ({
linkCount,
}: { linkCount: number } & PropsWithChildren) => {
const searchParams = useSearchParams();
const params = new URLSearchParams(searchParams);
const path = usePathname();
let [isPending, startTransition] = useTransition();
const { replace } = useRouter();

const handleCheckboxChange = () => {
if (!searchParams) return;

const params = new URLSearchParams(searchParams);
if (params.get('all') === 'true') {
params.delete('all');
} else {
Expand All @@ -28,6 +28,8 @@ export const BookmarksListControls = ({
});
};

if (params?.get('search') && !linkCount) return null;

return (
<div className="flex items-center justify-end gap-3 max-sm:w-full max-sm:justify-between">
<Switch
Expand Down

0 comments on commit 8e64c20

Please sign in to comment.