Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

refactor(questions): replace dropdown menu with direct edit/delete buttons in QuestionCard and update sidebar layout

Khuram Niaza923ca8b2dcd
diff --git a/e2e/questions.spec.ts b/e2e/questions.spec.ts
index 9d86242..195da0b 100644
--- a/e2e/questions.spec.ts
+++ b/e2e/questions.spec.ts
@@ -83,9 +83,8 @@ test.describe("Question Bank", () => {
).toBeVisible({ timeout: 10000 });
await questionCard(page, editQuestionText)
- .getByTestId("question-actions-menu-btn")
+ .getByTestId("question-edit-btn")
.click();
- await page.getByRole("menuitem", { name: "Edit" }).click();
await expect(page.getByTestId("question-form-dialog-title")).toBeVisible();
await expect(
page.getByPlaceholder("Enter interview question"),
@@ -118,10 +117,12 @@ test.describe("Question Bank", () => {
).toBeVisible({ timeout: 10000 });
await questionCard(page, deleteQuestionText)
- .getByTestId("question-actions-menu-btn")
+ .getByTestId("question-delete-btn")
+ .click();
+ await page
+ .getByRole("alertdialog")
+ .getByRole("button", { name: "Delete" })
.click();
- await page.getByRole("menuitem", { name: "Delete" }).click();
- await page.getByRole("button", { name: "Delete" }).click();
await expect(
page.getByRole("heading", { name: deleteQuestionText }),
@@ -147,8 +148,7 @@ test.describe("Question Bank", () => {
await expect(card).toBeVisible({ timeout: 10000 });
await expect(card.getByText(tagText, { exact: true })).toBeVisible();
- await card.getByTestId("question-actions-menu-btn").click();
- await page.getByRole("menuitem", { name: "Edit" }).click();
+ await card.getByTestId("question-edit-btn").click();
await expect(page.getByTestId("question-form-dialog-title")).toBeVisible();
// Scope to the dialog: the sidebar's tag filter button also renders the
// same tag label now that the question has been saved with it.
diff --git a/src/components/questions/QuestionCard.tsx b/src/components/questions/QuestionCard.tsx
index a582b4a..e451476 100644
--- a/src/components/questions/QuestionCard.tsx
+++ b/src/components/questions/QuestionCard.tsx
@@ -3,13 +3,7 @@ import { useState } from "react";
import { Question } from "@/models/question.model";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
-import { MoreVertical, Pencil, Trash2 } from "lucide-react";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu";
+import { Pencil, Trash2 } from "lucide-react";
import {
AlertDialog,
AlertDialogAction,
@@ -53,40 +47,34 @@ export function QuestionCard({
>
<div className="flex items-start justify-between gap-2">
<h3 className="font-medium flex-1">{question.question}</h3>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- variant="ghost"
- size="sm"
- className="h-8 w-8 p-0"
- onClick={(e) => e.stopPropagation()}
- data-testid="question-actions-menu-btn"
- >
- <MoreVertical className="h-4 w-4" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- onEdit(question);
- }}
- >
- <Pencil className="mr-2 h-4 w-4" />
- Edit
- </DropdownMenuItem>
- <DropdownMenuItem
- className="text-destructive"
- onClick={(e) => {
- e.stopPropagation();
- setShowDeleteDialog(true);
- }}
- >
- <Trash2 className="mr-2 h-4 w-4" />
- Delete
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
+ <div className="flex items-center gap-1">
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-8 px-2"
+ onClick={(e) => {
+ e.stopPropagation();
+ onEdit(question);
+ }}
+ data-testid="question-edit-btn"
+ >
+ <Pencil className="h-4 w-4 sm:mr-1" />
+ <span className="hidden sm:inline">Edit</span>
+ </Button>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-8 px-2 text-destructive hover:text-destructive"
+ onClick={(e) => {
+ e.stopPropagation();
+ setShowDeleteDialog(true);
+ }}
+ data-testid="question-delete-btn"
+ >
+ <Trash2 className="h-4 w-4 sm:mr-1" />
+ <span className="hidden sm:inline">Delete</span>
+ </Button>
+ </div>
</div>
{hasAnswer && (
diff --git a/src/components/questions/QuestionsSidebar.tsx b/src/components/questions/QuestionsSidebar.tsx
index 4df397e..fa92937 100644
--- a/src/components/questions/QuestionsSidebar.tsx
+++ b/src/components/questions/QuestionsSidebar.tsx
@@ -2,6 +2,7 @@
import { useState } from "react";
import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
+import { Badge } from "@/components/ui/badge";
type TagWithCount = {
id: string;
@@ -24,11 +25,14 @@ function QuestionsSidebar({
onFilterChange,
}: QuestionsSidebarProps) {
const [collapsed, setCollapsed] = useState(false);
+ const sortedTags = [...tags].sort(
+ (a, b) => b.questionCount - a.questionCount,
+ );
return (
<div
className={cn(
- "relative border-r py-4 hidden md:flex flex-col h-full transition-all duration-200",
+ "relative border-r py-4 hidden md:flex flex-col h-full transition-all duration-200 -ml-3",
collapsed ? "w-0 overflow-visible" : "w-48",
)}
>
@@ -46,47 +50,40 @@ function QuestionsSidebar({
{!collapsed && (
<>
- <h3 className="font-semibold mb-4 text-sm px-1">Skill Tags</h3>
- <ul className="space-y-1">
- <li>
- <button
- onClick={() => onFilterChange(undefined)}
+ <h3 className="font-semibold mb-4 text-sm">Skill Tags</h3>
+ <div className="flex flex-wrap gap-1.5">
+ <button onClick={() => onFilterChange(undefined)}>
+ <Badge
+ variant={!selectedFilter ? "default" : "secondary"}
className={cn(
- "w-full text-left px-3 py-2 rounded-md text-sm transition-colors",
- "hover:bg-accent hover:text-accent-foreground",
+ "cursor-pointer font-normal",
!selectedFilter &&
- "bg-accent text-accent-foreground font-medium",
+ "bg-blue-400 hover:bg-blue-400 text-white border-transparent",
)}
>
- <span className="flex justify-between items-center">
- <span>All</span>
- <span className="text-muted-foreground text-xs">
- {totalQuestions}
- </span>
- </span>
- </button>
- </li>
- {tags.map((tag) => (
- <li key={tag.id}>
- <button
- onClick={() => onFilterChange(tag.id)}
+ {totalQuestions} All
+ </Badge>
+ </button>
+ {sortedTags.map((tag) => (
+ <button
+ key={tag.id}
+ onClick={() => onFilterChange(tag.id)}
+ className="max-w-full"
+ title={`${tag.questionCount} ${tag.label}`}
+ >
+ <Badge
+ variant={selectedFilter === tag.id ? "default" : "secondary"}
className={cn(
- "w-full text-left px-3 py-2 rounded-md text-sm transition-colors",
- "hover:bg-accent hover:text-accent-foreground",
+ "cursor-pointer font-normal max-w-full whitespace-nowrap overflow-hidden text-ellipsis block",
selectedFilter === tag.id &&
- "bg-accent text-accent-foreground font-medium",
+ "bg-blue-400 hover:bg-blue-400 text-white border-transparent",
)}
>
- <span className="flex justify-between items-center">
- <span className="truncate">{tag.label}</span>
- <span className="text-muted-foreground text-xs">
- {tag.questionCount}
- </span>
- </span>
- </button>
- </li>
+ {tag.questionCount} {tag.label}
+ </Badge>
+ </button>
))}
- </ul>
+ </div>
</>
)}
</div>