Skip to content

Commit 710f441

Browse files
committed
feat: add visual feedback for context menu selection in file explorer
Add highlighted background and ring border to file explorer items when their context menu is open, providing clear visual indication of which item the context menu belongs to.
1 parent 5d516f7 commit 710f441

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src-frontend/components/workspace/file-explorer.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ const FileExplorerItem = React.memo(function FileExplorerItem({
380380
}: FileExplorerItemProps) {
381381
const { addFavorite } = useSidebarStore();
382382
const [platform, setPlatform] = useState<string>("macos");
383+
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false);
383384

384385
useEffect(() => {
385386
const { platform } =
@@ -418,11 +419,14 @@ const FileExplorerItem = React.memo(function FileExplorerItem({
418419
const itemClasses = cn(
419420
`group cursor-pointer rounded-lg ${ITEM_PADDING} transition-colors relative flex items-center justify-center`,
420421
viewMode === "grid" ? `${GRID_ITEM_SIZE} shrink-0 grow-0` : "w-full",
421-
selectedItems.includes(item.path) ? "bg-accent" : "hover:bg-muted",
422+
selectedItems.includes(item.path) || isContextMenuOpen
423+
? "bg-accent"
424+
: "hover:bg-muted",
422425
dropTarget === item.id && "ring-1 ring-primary",
423426
viewMode === "list" && "justify-start gap-3",
424427
document.activeElement?.id === `file-item-${item.id}` &&
425428
"ring-2 ring-primary animate-pulse",
429+
isContextMenuOpen && "ring-2 ring-accent-foreground/50",
426430
);
427431

428432
const contentClasses = cn(
@@ -445,7 +449,7 @@ const FileExplorerItem = React.memo(function FileExplorerItem({
445449
);
446450

447451
return (
448-
<ContextMenu>
452+
<ContextMenu onOpenChange={setIsContextMenuOpen}>
449453
<ContextMenuTrigger asChild>
450454
<motion.div
451455
id={`file-item-${item.id}`}

0 commit comments

Comments
 (0)