Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
WarningIcon,
XIcon,
} from "@phosphor-icons/react";
import { Kbd } from "@posthog/quill";
import {
Box,
Flex,
Expand All @@ -46,7 +47,14 @@ import type {
} from "@shared/types";
import { useNavigationStore } from "@stores/navigationStore";
import { useQuery } from "@tanstack/react-query";
import { type ReactNode, useCallback, useMemo, useState } from "react";
import { isMac } from "@utils/platform";
import {
type ReactNode,
useCallback,
useEffect,
useMemo,
useState,
} from "react";
import { toast } from "sonner";
import { ReportImplementationPrLink } from "../utils/ReportImplementationPrLink";
import { SignalReportActionabilityBadge } from "../utils/SignalReportActionabilityBadge";
Expand Down Expand Up @@ -280,6 +288,31 @@ export function ReportDetailPane({
report,
]);

useEffect(() => {
if (!canCreateImplementationPr) return;
const handler = (e: KeyboardEvent) => {
if (e.key !== "Enter") return;
if (!(e.metaKey || e.ctrlKey)) return;
if (
document.querySelector(
"[data-radix-popper-content-wrapper], [role='dialog'][data-state='open']",
)
) {
return;
}
const target = e.target as HTMLElement | null;
if (
target?.closest("input, select, textarea, [contenteditable='true']")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The [contenteditable='true'] selector only matches elements that explicitly set contenteditable="true". Many rich-text editors (ProseMirror, CodeMirror, Slate, Tiptap) set the attribute as contenteditable (bare attribute) or contenteditable="", which HTML treats as true but the CSS attribute selector [contenteditable='true'] won't match. If any future dialog renders such an editor, Cmd+Enter would fire the task-creation shortcut unexpectedly.

Suggested change
target?.closest("input, select, textarea, [contenteditable='true']")
target?.closest("input, select, textarea, [contenteditable]:not([contenteditable='false'])")
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/inbox/components/detail/ReportDetailPane.tsx
Line: 303

Comment:
The `[contenteditable='true']` selector only matches elements that explicitly set `contenteditable="true"`. Many rich-text editors (ProseMirror, CodeMirror, Slate, Tiptap) set the attribute as `contenteditable` (bare attribute) or `contenteditable=""`, which HTML treats as true but the CSS attribute selector `[contenteditable='true']` won't match. If any future dialog renders such an editor, Cmd+Enter would fire the task-creation shortcut unexpectedly.

```suggestion
        target?.closest("input, select, textarea, [contenteditable]:not([contenteditable='false'])")
```

How can I resolve this? If you propose a fix, please make it concise.

) {
return;
}
e.preventDefault();
handleCreateImplementationTask();
};
window.addEventListener("keydown", handler);
return () => window.removeEventListener("keydown", handler);
}, [canCreateImplementationPr, handleCreateImplementationTask]);

return (
<>
{/* ── Header bar ──────────────────────────────────────────── */}
Expand Down Expand Up @@ -343,15 +376,23 @@ export function ReportDetailPane({
size="md"
/>
) : canCreateImplementationPr ? (
<Button
size="1"
variant="solid"
className="gap-1 text-[12px]"
onClick={handleCreateImplementationTask}
<Tooltip
content={
<Flex align="center" gap="1">
Create PR <Kbd>{isMac ? "⌘↵" : "Ctrl+↵"}</Kbd>
</Flex>
}
>
<Plus size={12} />
Create PR
</Button>
<Button
size="1"
variant="solid"
className="gap-1 text-[12px]"
onClick={handleCreateImplementationTask}
>
<Plus size={12} />
Create PR
</Button>
</Tooltip>
) : null}
<button
type="button"
Expand Down
Loading