diff --git a/peerprep-fe/src/app/(main)/components/filter/TopicsPopover.tsx b/peerprep-fe/src/app/(main)/components/filter/TopicsPopover.tsx index c196d53ad9..bdaf27c6b0 100644 --- a/peerprep-fe/src/app/(main)/components/filter/TopicsPopover.tsx +++ b/peerprep-fe/src/app/(main)/components/filter/TopicsPopover.tsx @@ -48,18 +48,16 @@ export function TopicsPopover({ const handleTopicSelection = (selectedTopic: string) => { if (multiselect) { - // Multiple selection mode const newSelectedTopics = selectedTopics.includes(selectedTopic) ? selectedTopics.filter((t) => t !== selectedTopic) : [...selectedTopics, selectedTopic]; onChange(newSelectedTopics); } else { - // Single selection mode const newSelectedTopics = selectedTopics.includes(selectedTopic) - ? [] // Deselect if clicking the same topic - : [selectedTopic]; // Select only the clicked topic + ? [] + : [selectedTopic]; onChange(newSelectedTopics); - setOpen(false); // Close popover after selection in single select mode + setOpen(false); } }; @@ -116,18 +114,18 @@ export function TopicsPopover({ ))}