diff --git a/packages/plugins/examples/plugin-file-browser-example/src/ui/index.tsx b/packages/plugins/examples/plugin-file-browser-example/src/ui/index.tsx index d47acc53c8..e75435771e 100644 --- a/packages/plugins/examples/plugin-file-browser-example/src/ui/index.tsx +++ b/packages/plugins/examples/plugin-file-browser-example/src/ui/index.tsx @@ -794,8 +794,15 @@ export function CommentOpenFiles({ context }: PluginCommentContextMenuItemProps) setOpen(false); } } + function handleKeyDown(e: globalThis.KeyboardEvent) { + if (e.key === "Escape") setOpen(false); + } document.addEventListener("mousedown", handleClickOutside); - return () => document.removeEventListener("mousedown", handleClickOutside); + document.addEventListener("keydown", handleKeyDown); + return () => { + document.removeEventListener("mousedown", handleClickOutside); + document.removeEventListener("keydown", handleKeyDown); + }; }, [open]); if (mode === "annotation" || mode === "none") return null; @@ -805,24 +812,11 @@ export function CommentOpenFiles({ context }: PluginCommentContextMenuItemProps) const projectId = context.projectId; return ( -
+
{open && ( -
-
+
+
Referenced files
{data.links.map((link) => { @@ -869,27 +843,15 @@ export function CommentOpenFiles({ context }: PluginCommentContextMenuItemProps) href={href} onClick={(e) => { navigateToFileBrowser(href, e); setOpen(false); }} title={link} - style={{ - display: "flex", - alignItems: "center", - gap: "0.5rem", - padding: "0.375rem 0.5rem", - borderRadius: "0.375rem", - fontSize: "0.75rem", - color: "var(--foreground, #0f172a)", - textDecoration: "none", - transition: "background 0.1s", - }} - onMouseEnter={(e) => { (e.currentTarget as HTMLElement).style.background = "var(--accent, #f1f5f9)"; }} - onMouseLeave={(e) => { (e.currentTarget as HTMLElement).style.background = "transparent"; }} + className="flex items-center gap-2 px-2 py-1.5 rounded-md text-xs text-foreground no-underline transition-colors hover:bg-accent" > - {fileName} + {fileName} {fileName !== link && ( - + {link} )}