Skip to content

Commit 23b7edb

Browse files
committed
Implemented PR feedback
1 parent f6b467f commit 23b7edb

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

packages/core/src/comments/extension.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,20 @@ export const CommentsExtension = createExtension(
245245
mark.type.name === markType && mark.attrs.orphan !== true,
246246
);
247247

248-
const threadId = commentMark?.attrs.threadId as
249-
| string
250-
| undefined;
248+
if (!commentMark) {
249+
// Clicked outside any comment thread. Deselect if needed but
250+
// don't consume the event so other handlers (e.g. link
251+
// navigation) can process it.
252+
if (store.state.selectedThreadId !== undefined) {
253+
store.setState((prev) => ({
254+
...prev,
255+
selectedThreadId: undefined,
256+
}));
257+
}
258+
return false;
259+
}
260+
261+
const threadId = commentMark.attrs.threadId as string;
251262

252263
// If the clicked thread is already selected, do nothing and let
253264
// other handlers process the event (e.g. navigating a link).

0 commit comments

Comments
 (0)