From 69fdebd573ca53719126b7003cd67a256cc84c47 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 12 Jul 2026 23:05:22 +0200 Subject: [PATCH] fix: Comment gutter mark default enabled (#12977) --- app/editor/extensions/CommentGutter.tsx | 4 +++- app/scenes/Document/components/Editor.tsx | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/editor/extensions/CommentGutter.tsx b/app/editor/extensions/CommentGutter.tsx index 29ef213795..61be878ade 100644 --- a/app/editor/extensions/CommentGutter.tsx +++ b/app/editor/extensions/CommentGutter.tsx @@ -6,6 +6,7 @@ import Extension from "@shared/editor/lib/Extension"; import { changedDescendants } from "@shared/editor/lib/changedDescendants"; import { isRemoteTransaction } from "@shared/editor/lib/multiplayer"; import { EditorStyleHelper } from "@shared/editor/styles/EditorStyleHelper"; +import { UserPreferenceDefaults } from "@shared/constants"; import { UserPreference } from "@shared/types"; import { CommentGutter as CommentGutterComponent } from "../components/CommentGutter"; @@ -25,7 +26,8 @@ export default class CommentGutter extends Extension { get plugins() { const isEnabled = () => - !!this.editor.props.userPreferences?.[UserPreference.CommentsInGutter]; + this.editor.props.userPreferences?.[UserPreference.CommentsInGutter] ?? + UserPreferenceDefaults[UserPreference.CommentsInGutter]; const handleClickCommentMark = (commentId: string) => this.editor.props.onClickCommentMark?.(commentId); diff --git a/app/scenes/Document/components/Editor.tsx b/app/scenes/Document/components/Editor.tsx index 85ce6e8040..234fbadd9d 100644 --- a/app/scenes/Document/components/Editor.tsx +++ b/app/scenes/Document/components/Editor.tsx @@ -156,6 +156,16 @@ function DocumentEditor(props: Props, ref: React.ForwardedRef) { [comments, user?.id, props.id, setFocusedCommentId] ); + // Focus a comment and open the sidebar when its mark or gutter marker is + // clicked. + const handleClickCommentMark = React.useCallback( + (commentId: string) => { + setFocusedCommentId(commentId); + ui.set({ rightSidebar: "comments" }); + }, + [setFocusedCommentId, ui] + ); + // Soft delete the Comment model when associated mark is totally removed. const handleRemoveComment = React.useCallback( async (commentId: string) => { @@ -245,7 +255,7 @@ function DocumentEditor(props: Props, ref: React.ForwardedRef) { userId={user?.id} focusedCommentId={focusedComment?.id} onClickCommentMark={ - commentingEnabled && can.comment ? setFocusedCommentId : undefined + commentingEnabled && can.comment ? handleClickCommentMark : undefined } onCreateCommentMark={ commentingEnabled && can.comment ? handleDraftComment : undefined