Skip to content

Commit 99986b3

Browse files
committed
fix(webview): keep expanded task panel open after mention click
The mention span handler in MarkdownBlock now stops propagation before posting openMention, so a mention click inside the expanded task header no longer bubbles to the TaskHeader toggle and collapses the panel. Adds a regression assertion that the expanded markdown stays rendered after clicking a mention. Addresses CodeRabbit review comment on PR #1257.
1 parent 3811f0b commit 99986b3

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎webview-ui/src/components/chat/__tests__/TaskHeader.spec.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,12 @@ describe("TaskHeader", () => {
427427

428428
fireEvent.click(mentions[0])
429429
expect(mockPostMessage).toHaveBeenCalledWith({ type: "openMention", text: "/src/file.ts" })
430+
431+
// The mention click must not bubble to the header toggle (the mention handler
432+
// stops propagation), so the expanded markdown stays rendered after the
433+
// mention is opened instead of the panel collapsing.
434+
expect(screen.getByText(/Inspect/, { exact: false })).toBeInTheDocument()
435+
expect(container.querySelectorAll("span.mention-context-highlight")).toHaveLength(3)
430436
})
431437

432438
it("renders an empty prompt without crashing", () => {

‎webview-ui/src/components/common/MarkdownBlock.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ function rehypeMentions() {
4949
tagName: "span",
5050
properties: {
5151
className: ["mention-context-highlight", "text-[0.9em]", "cursor-pointer"],
52-
onClick: () => vscode.postMessage({ type: "openMention", text: mentionValue }),
52+
onClick: (event: React.MouseEvent<HTMLSpanElement>) => {
53+
// Keep mention clicks from bubbling to the TaskHeader toggle, which
54+
// would collapse the expanded panel right after opening the mention.
55+
event.stopPropagation()
56+
vscode.postMessage({ type: "openMention", text: mentionValue })
57+
},
5358
},
5459
children: [{ type: "text", value: mentionText }],
5560
})

0 commit comments

Comments
 (0)