Skip to content

Commit

Permalink
refactor unnecessary Id splitting and pass the document id to onSelect
Browse files Browse the repository at this point in the history
  • Loading branch information
adityaphasu committed Sep 17, 2024
1 parent 454bca7 commit c2e2864
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions components/search-command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ export const SearchCommand = () => {
}, [toggle]);

const onSelect = (id: string) => {
const splitId = id.split("-")[0];
router.push(`/documents/${splitId}`);
router.push(`/documents/${id}`);
onClose();
};

Expand All @@ -64,7 +63,7 @@ export const SearchCommand = () => {
key={document._id}
value={`${document._id}-${document.title}`}
title={document.title}
onSelect={onSelect}
onSelect={() => onSelect(document._id)}
>
{document.icon ? (
<p className="mr-2 text-[1.125rem]">{document.icon}</p>
Expand Down

0 comments on commit c2e2864

Please sign in to comment.